Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unlink old final artifacts before compilation #11122

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: renamed uplifted artifact remains unmodified after rebuild
  • Loading branch information
weihanglo committed Sep 21, 2022
commit bf1523b663bba1f514d5f468f6c771e8a479afbf
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
29 changes: 29 additions & 0 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}