Skip to content

Commit

Permalink
test(freshness): check that updating dependency mtime does not rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
schomatis committed Jun 21, 2019
1 parent 37cb9bb commit 9aa7a4d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,49 @@ fn simple_deps_cleaner_does_not_rebuild() {
.run();
}

#[cargo_test]
fn update_dependency_mtime_does_not_rebuild() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
[dependencies]
bar = { path = "bar" }
"#,
)
.file("src/lib.rs", "")
.file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1"))
.file("bar/src/lib.rs", "")
.build();

p.cargo("build -Z mtime-on-use")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-C target-cpu=native")
.with_stderr(
"\
[COMPILING] bar v0.0.1 ([..])
[COMPILING] foo v0.0.1 ([..])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
)
.run();
// This does not make new files, but it does update the mtime of the dependency.
p.cargo("build -p bar -Z mtime-on-use")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-C target-cpu=native")
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
.run();
// This should not recompile!
p.cargo("build -Z mtime-on-use")
.masquerade_as_nightly_cargo()
.env("RUSTFLAGS", "-C target-cpu=native")
.with_stderr("[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")
.run();
}

fn fingerprint_cleaner(mut dir: PathBuf, timestamp: filetime::FileTime) {
// Cargo is experimenting with letting outside projects develop some
// limited forms of GC for target_dir. This is one of the forms.
Expand Down

0 comments on commit 9aa7a4d

Please sign in to comment.