Skip to content

Commit 97363ca

Browse files
committed
fix tests on HFS
1 parent e31003a commit 97363ca

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tests/testsuite/freshness.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,7 @@ fn simple_deps_cleaner(mut dir: PathBuf, timestamp: filetime::FileTime) {
11931193
let dep = dep.unwrap();
11941194
if filetime::FileTime::from_last_modification_time(&dep.metadata().unwrap()) <= timestamp {
11951195
fs::remove_file(dep.path()).unwrap();
1196+
println!("remove: {:?}", dep.path());
11961197
cleand = true;
11971198
}
11981199
}
@@ -1235,6 +1236,9 @@ fn simple_deps_cleaner_dose_not_rebuild() {
12351236
sleep_ms(1000);
12361237
}
12371238
let timestamp = filetime::FileTime::from_system_time(SystemTime::now());
1239+
if is_coarse_mtime() {
1240+
sleep_ms(1000);
1241+
}
12381242
// This dose not make new files, but it dose update the mtime.
12391243
p.cargo("build")
12401244
.env("RUSTFLAGS", "-C target-cpu=native")
@@ -1275,6 +1279,7 @@ fn fingerprint_cleaner(mut dir: PathBuf, timestamp: filetime::FileTime) {
12751279
<= timestamp
12761280
}) {
12771281
fs::remove_dir_all(fing.path()).unwrap();
1282+
println!("remove: {:?}", fing.path());
12781283
// a real cleaner would remove the big files in deps and build as well
12791284
// but fingerprint is sufficient for our tests
12801285
cleand = true;
@@ -1320,6 +1325,9 @@ fn fingerprint_cleaner_dose_not_rebuild() {
13201325
sleep_ms(1000);
13211326
}
13221327
let timestamp = filetime::FileTime::from_system_time(SystemTime::now());
1328+
if is_coarse_mtime() {
1329+
sleep_ms(1000);
1330+
}
13231331
// This dose not make new files, but it dose update the mtime.
13241332
p.cargo("build")
13251333
.env("RUSTFLAGS", "-C target-cpu=native")

tests/testsuite/support/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,9 @@ pub fn sleep_ms(ms: u64) {
16031603

16041604
/// Returns true if the local filesystem has low-resolution mtimes.
16051605
pub fn is_coarse_mtime() -> bool {
1606+
// If the filetime crate is being used to emulate HFS then
1607+
// return true, without looking at the actual hardware.
1608+
cfg!(emulate_second_only_system) ||
16061609
// This should actually be a test that $CARGO_TARGET_DIR is on an HFS
16071610
// filesystem, (or any filesystem with low-resolution mtimes). However,
16081611
// that's tricky to detect, so for now just deal with CI.

0 commit comments

Comments
 (0)