Skip to content

Commit 6f40a3e

Browse files
committed
test(package): generated file not have deterministic timestamp
We only set deterministic timestamp for actual file we copy cover during `cargo package`ing. Generated files should actually follow.
1 parent 8c4a25c commit 6f40a3e

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/testsuite/package.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,12 +3162,27 @@ fn reproducible_output() {
31623162
let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap();
31633163
let decoder = GzDecoder::new(f);
31643164
let mut archive = Archive::new(decoder);
3165+
3166+
// Hardcoded value be removed once alexcrichton/tar-rs#420 is merged and released.
3167+
// See also rust-lang/cargo#16237
3168+
const DETERMINISTIC_TIMESTAMP: u64 = 1153704088;
31653169
for ent in archive.entries().unwrap() {
31663170
let ent = ent.unwrap();
31673171
println!("checking {:?}", ent.path());
31683172
let header = ent.header();
31693173
assert_eq!(header.mode().unwrap(), 0o644);
31703174
assert!(header.mtime().unwrap() != 0);
3175+
// Generated files do not have deterministic timestamp (yet).
3176+
let path = ent.path().unwrap();
3177+
let file_name = path.file_name().unwrap().to_str().unwrap();
3178+
if ["Cargo.toml", "Cargo.lock", ".cargo_vcs_info.json"]
3179+
.into_iter()
3180+
.any(|f| f == file_name)
3181+
{
3182+
assert!(header.mtime().unwrap() != DETERMINISTIC_TIMESTAMP);
3183+
} else {
3184+
assert!(header.mtime().unwrap() == DETERMINISTIC_TIMESTAMP);
3185+
}
31713186
assert_eq!(header.username().unwrap().unwrap(), "");
31723187
assert_eq!(header.groupname().unwrap().unwrap(), "");
31733188
}

0 commit comments

Comments
 (0)