diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 2814966b51f..e21ded04345 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1193,6 +1193,7 @@ fn simple_deps_cleaner(mut dir: PathBuf, timestamp: filetime::FileTime) { let dep = dep.unwrap(); if filetime::FileTime::from_last_modification_time(&dep.metadata().unwrap()) <= timestamp { fs::remove_file(dep.path()).unwrap(); + println!("remove: {:?}", dep.path()); cleand = true; } } @@ -1235,6 +1236,9 @@ fn simple_deps_cleaner_dose_not_rebuild() { sleep_ms(1000); } let timestamp = filetime::FileTime::from_system_time(SystemTime::now()); + if is_coarse_mtime() { + sleep_ms(1000); + } // This dose not make new files, but it dose update the mtime. p.cargo("build") .env("RUSTFLAGS", "-C target-cpu=native") @@ -1275,6 +1279,7 @@ fn fingerprint_cleaner(mut dir: PathBuf, timestamp: filetime::FileTime) { <= timestamp }) { fs::remove_dir_all(fing.path()).unwrap(); + println!("remove: {:?}", fing.path()); // a real cleaner would remove the big files in deps and build as well // but fingerprint is sufficient for our tests cleand = true; @@ -1320,6 +1325,9 @@ fn fingerprint_cleaner_dose_not_rebuild() { sleep_ms(1000); } let timestamp = filetime::FileTime::from_system_time(SystemTime::now()); + if is_coarse_mtime() { + sleep_ms(1000); + } // This dose not make new files, but it dose update the mtime. p.cargo("build") .env("RUSTFLAGS", "-C target-cpu=native") diff --git a/tests/testsuite/support/mod.rs b/tests/testsuite/support/mod.rs index 47e681460fb..404439ea416 100644 --- a/tests/testsuite/support/mod.rs +++ b/tests/testsuite/support/mod.rs @@ -1603,6 +1603,9 @@ pub fn sleep_ms(ms: u64) { /// Returns true if the local filesystem has low-resolution mtimes. pub fn is_coarse_mtime() -> bool { + // If the filetime crate is being used to emulate HFS then + // return true, without looking at the actual hardware. + cfg!(emulate_second_only_system) || // This should actually be a test that $CARGO_TARGET_DIR is on an HFS // filesystem, (or any filesystem with low-resolution mtimes). However, // that's tricky to detect, so for now just deal with CI.