Skip to content

Commit

Permalink
fix tests on HFS
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Jan 13, 2019
1 parent e31003a commit 97363ca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/testsuite/freshness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions tests/testsuite/support/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 97363ca

Please sign in to comment.