Skip to content

Commit

Permalink
Auto merge of #13143 - ChrisDenton:test-changes, r=weihanglo
Browse files Browse the repository at this point in the history
Don't rely on mtime to test changes

### What does this PR try to resolve?

Fixes #13139 by making sure tests aren't relying on changing the mtime alone

### How should we test and review this PR?

The pattern to watch out for is when a file is created with empty contents, e.g. `.file("foo", "")`, then later the same file updated with empty contents, e.g. `.change_file("foo", "")`. Tests should be making an actual change to the contents.
  • Loading branch information
bors committed Dec 8, 2023
2 parents a1449ee + 4ef503f commit 047dc18
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3471,7 +3471,7 @@ fn rebuild_only_on_explicit_paths() {

// random other files do not affect freshness
println!("run baz");
p.change_file("baz", "");
p.change_file("baz", "// modified");
p.cargo("build -v")
.with_stderr(
"\
Expand All @@ -3483,7 +3483,7 @@ fn rebuild_only_on_explicit_paths() {

// but changing dependent files does
println!("run foo change");
p.change_file("foo", "");
p.change_file("foo", "// modified");
p.cargo("build -v")
.with_stderr(
"\
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/build_script_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn rerun_if_env_or_file_changes() {
.with_stderr("[FINISHED] [..]")
.run();
sleep_ms(1000);
p.change_file("foo", "");
p.change_file("foo", "// modified");
p.cargo("check")
.env("FOO", "bar")
.with_stderr(
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,7 @@ fn bust_patched_dep() {
sleep_ms(1000);
}

p.change_file("reg1new/src/lib.rs", "");
p.change_file("reg1new/src/lib.rs", "// modified");
if is_coarse_mtime() {
sleep_ms(1000);
}
Expand Down

0 comments on commit 047dc18

Please sign in to comment.