test: renamed uplifted artifact remains unmodified after rebuild

This commit is contained in:
Weihang Lo 2022-09-21 12:55:32 +01:00
parent 531ce1321d
commit bf1523b663
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7
2 changed files with 30 additions and 0 deletions

View File

@ -99,6 +99,7 @@ features = [
[dev-dependencies]
cargo-test-macro = { path = "crates/cargo-test-macro" }
cargo-test-support = { path = "crates/cargo-test-support" }
same-file = "1.0.6"
snapbox = { version = "0.3.0", features = ["diff", "path"] }
[build-dependencies]

View File

@ -6247,3 +6247,32 @@ fn primary_package_env_var() {
foo.cargo("test").run();
}
#[cargo_test]
fn renamed_uplifted_artifact_remains_unmodified_after_rebuild() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
authors = []
version = "0.0.0"
"#,
)
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("build").run();
let bin = p.bin("foo");
let renamed_bin = p.bin("foo-renamed");
fs::rename(&bin, &renamed_bin).unwrap();
p.change_file("src/main.rs", "fn main() { eprintln!(\"hello, world\"); }");
p.cargo("build").run();
let not_the_same = !same_file::is_same_file(bin, renamed_bin).unwrap();
assert!(not_the_same, "renamed uplifted artifact must be unmodified");
}