Skip to content

Commit 6f2b5d9

Browse files
committed
test(depinfo): current cargo unable to parse v0 or v1
We're going to add the magic marker in the next commit. The v0 test is to ensure that we don't change anything unexpected.
1 parent 1fcf5ee commit 6f2b5d9

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/cargo/core/compiler/fingerprint/dep_info.rs

+31
Original file line numberDiff line numberDiff line change
@@ -667,4 +667,35 @@ mod encoded_dep_info {
667667
fn round_trip_with_checksums() {
668668
gen_test(true);
669669
}
670+
671+
#[test]
672+
fn path_type_is_u8_max() {
673+
#[rustfmt::skip]
674+
let data = [
675+
0x01, 0x00, 0x00, 0x00, 0xff, // magic marker
676+
0x01, // version
677+
0x01, 0x00, 0x00, 0x00, // # of files
678+
0x00, // path type
679+
0x04, 0x00, 0x00, 0x00, // len of path
680+
0x72, 0x75, 0x73, 0x74, // path bytes ("rust")
681+
0x00, // cksum exists?
682+
0x00, 0x00, 0x00, 0x00, // # of env vars
683+
];
684+
// The current cargo doesn't recognize the magic marker.
685+
assert!(EncodedDepInfo::parse(&data).is_none());
686+
}
687+
688+
#[test]
689+
fn parse_v0_fingerprint_dep_info() {
690+
#[rustfmt::skip]
691+
let data = [
692+
0x01, 0x00, 0x00, 0x00, // # of files
693+
0x00, // path type
694+
0x04, 0x00, 0x00, 0x00, // len of path
695+
0x72, 0x75, 0x73, 0x74, // path bytes: "rust"
696+
0x00, 0x00, 0x00, 0x00, // # of env vars
697+
];
698+
// Cargo can't recognize v0 after `-Zchecksum-freshess` added.
699+
assert!(EncodedDepInfo::parse(&data).is_none());
700+
}
670701
}

0 commit comments

Comments
 (0)