From 8320bbe8ed34ddff59234c035634faadd00fc3df Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 30 Apr 2018 13:29:16 -0400 Subject: [PATCH 1/7] add failing test --- tests/testsuite/build.rs | 115 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 4d9cc80e04d..2f6d5debec7 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1,6 +1,8 @@ use std::env; -use std::fs::{self, File}; +use std::fs::{self, File, OpenOptions}; use std::io::prelude::*; +use std::net::TcpListener; +use std::thread; use crate::support::paths::{root, CargoPathExt}; use crate::support::registry::Package; @@ -2394,6 +2396,117 @@ fn rebuild_preserves_out_dir() { .run(); } +#[test] +fn rebuild_on_mid_build_file_modification() { + let server = TcpListener::bind("127.0.0.1:0").unwrap(); + let addr = server.local_addr().unwrap(); + + let p = project("p") + .file( + "Cargo.toml", + r#" + [workspace] + members = ["root", "proc_macro_dep"] + "#, + ) + .file( + "root/Cargo.toml", + r#" + [project] + name = "root" + version = "0.1.0" + authors = [] + + [dependencies] + proc_macro_dep = { path = "../proc_macro_dep" } + "#, + ) + .file( + "root/src/lib.rs", + r#" + #[macro_use] + extern crate proc_macro_dep; + + #[derive(Noop)] + pub struct X; + "#, + ) + .file( + "proc_macro_dep/Cargo.toml", + r#" + [project] + name = "proc_macro_dep" + version = "0.1.0" + authors = [] + + [lib] + proc-macro = true + "#, + ) + .file( + "proc_macro_dep/src/lib.rs", + &format!( + r#" + extern crate proc_macro; + + use std::io::Read; + use std::net::TcpStream; + use proc_macro::TokenStream; + + #[proc_macro_derive(Noop)] + pub fn noop(_input: TokenStream) -> TokenStream {{ + let mut stream = TcpStream::connect("{}").unwrap(); + let mut v = Vec::new(); + stream.read_to_end(&mut v).unwrap(); + "".parse().unwrap() + }} + "#, + addr + ), + ) + .build(); + let root = p.root(); + + let t = thread::spawn(move || { + let socket = server.accept().unwrap().0; + let mut file = OpenOptions::new() + .write(true) + .append(true) + .open(root.join("root/src/lib.rs")) + .unwrap(); + writeln!(file, "// modified").expect("Failed to append to root sources"); + drop(file); + drop(socket); + drop(server.accept().unwrap()); + }); + + assert_that( + p.cargo("build"), + execs().stream().with_status(0) +// .with_stderr(&format!( +// "\ +//[COMPILING] proc_macro_dep v0.1.0 ({url}/proc_macro_dep) +//[COMPILING] root v0.1.0 ({url}/root) +//[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +//", +// url = p.url() +// )), + ); + + assert_that( + p.cargo("build"), + execs().stream().with_status(0).with_stderr(&format!( + "\ +[COMPILING] root v0.1.0 ({url}/root) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + url = p.url() + )), + ); + + t.join().ok().unwrap(); +} + #[test] fn dep_no_libs() { let foo = project() From b10639011051290a68f583357196c206719d60f2 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Tue, 25 Dec 2018 14:54:26 -0500 Subject: [PATCH 2/7] update test for new idioms --- tests/testsuite/build.rs | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 2f6d5debec7..83eeffbda16 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -2401,7 +2401,7 @@ fn rebuild_on_mid_build_file_modification() { let server = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = server.local_addr().unwrap(); - let p = project("p") + let p = project() .file( "Cargo.toml", r#" @@ -2480,29 +2480,24 @@ fn rebuild_on_mid_build_file_modification() { drop(server.accept().unwrap()); }); - assert_that( - p.cargo("build"), - execs().stream().with_status(0) -// .with_stderr(&format!( -// "\ -//[COMPILING] proc_macro_dep v0.1.0 ({url}/proc_macro_dep) -//[COMPILING] root v0.1.0 ({url}/root) -//[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -//", -// url = p.url() -// )), - ); - - assert_that( - p.cargo("build"), - execs().stream().with_status(0).with_stderr(&format!( + p.cargo("build") + .with_stderr( "\ -[COMPILING] root v0.1.0 ({url}/root) +[COMPILING] proc_macro_dep v0.1.0 ([..]/proc_macro_dep) +[COMPILING] root v0.1.0 ([..]/root) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - url = p.url() - )), - ); + ) + .run(); + + p.cargo("build") + .with_stderr( + "\ +[COMPILING] root v0.1.0 ([..]/root) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); t.join().ok().unwrap(); } From d2c71cace48bec6548792e9f106740ad511de1e2 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Tue, 25 Dec 2018 15:19:46 -0500 Subject: [PATCH 3/7] minimal changes to get the test to pass --- src/cargo/core/compiler/custom_build.rs | 4 ++++ src/cargo/core/compiler/fingerprint.rs | 8 ++++---- src/cargo/core/compiler/mod.rs | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index fad916d0443..391a2b7cf4b 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -332,6 +332,10 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes state.build_plan(invocation_name, cmd.clone(), Arc::new(Vec::new())); } else { state.running(&cmd); + paths::write( + &output_file.with_file_name("invoked.timestamp"), + b"This file has an mtime of when this build-script was started.", + )?; let output = if extra_verbose { let prefix = format!("[{} {}] ", id.name(), id.version()); state.capture_output(&cmd, Some(prefix), true) diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 62daeed05fa..5fd44dd1e7f 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -239,7 +239,7 @@ impl Fingerprint { for local in self.local.iter() { match *local { LocalFingerprint::MtimeBased(ref slot, ref path) => { - let path = root.join(path); + let path = root.join(&path.with_file_name("invoked.timestamp")); let mtime = paths::mtime(&path)?; *slot.0.lock().unwrap() = Some(mtime); } @@ -746,7 +746,7 @@ where I: IntoIterator, I::Item: AsRef, { - let mtime = match paths::mtime(output) { + let mtime = match paths::mtime(&output.with_file_name("invoked.timestamp")) { Ok(mtime) => mtime, Err(..) => return None, }; @@ -764,14 +764,14 @@ where // Note that equal mtimes are considered "stale". For filesystems with // not much timestamp precision like 1s this is a conservative approximation // to handle the case where a file is modified within the same second after - // a build finishes. We want to make sure that incremental rebuilds pick that up! + // a build starts. We want to make sure that incremental rebuilds pick that up! // // For filesystems with nanosecond precision it's been seen in the wild that // its "nanosecond precision" isn't really nanosecond-accurate. It turns out that // kernels may cache the current time so files created at different times actually // list the same nanosecond precision. Some digging on #5919 picked up that the // kernel caches the current time between timer ticks, which could mean that if - // a file is updated at most 10ms after a build finishes then Cargo may not + // a file is updated at most 10ms after a build starts then Cargo may not // pick up the build changes. // // All in all, the equality check here is a conservative assumption that, diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 1c6f47b41e4..bbb1f686b25 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -292,6 +292,10 @@ fn rustc<'a, 'cfg>( } state.running(&rustc); + paths::write( + &dep_info_loc.with_file_name("invoked.timestamp"), + b"This file has an mtime of when rustc was started.", + )?; if json_messages { exec.exec_json( rustc, From 03a6b6e7ada51ba8a7d9cc1a72257afe549543d3 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Fri, 28 Dec 2018 10:15:25 -0500 Subject: [PATCH 4/7] move the test --- tests/testsuite/build.rs | 110 +---------------------------------- tests/testsuite/freshness.rs | 110 ++++++++++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 110 deletions(-) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 83eeffbda16..4d9cc80e04d 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1,8 +1,6 @@ use std::env; -use std::fs::{self, File, OpenOptions}; +use std::fs::{self, File}; use std::io::prelude::*; -use std::net::TcpListener; -use std::thread; use crate::support::paths::{root, CargoPathExt}; use crate::support::registry::Package; @@ -2396,112 +2394,6 @@ fn rebuild_preserves_out_dir() { .run(); } -#[test] -fn rebuild_on_mid_build_file_modification() { - let server = TcpListener::bind("127.0.0.1:0").unwrap(); - let addr = server.local_addr().unwrap(); - - let p = project() - .file( - "Cargo.toml", - r#" - [workspace] - members = ["root", "proc_macro_dep"] - "#, - ) - .file( - "root/Cargo.toml", - r#" - [project] - name = "root" - version = "0.1.0" - authors = [] - - [dependencies] - proc_macro_dep = { path = "../proc_macro_dep" } - "#, - ) - .file( - "root/src/lib.rs", - r#" - #[macro_use] - extern crate proc_macro_dep; - - #[derive(Noop)] - pub struct X; - "#, - ) - .file( - "proc_macro_dep/Cargo.toml", - r#" - [project] - name = "proc_macro_dep" - version = "0.1.0" - authors = [] - - [lib] - proc-macro = true - "#, - ) - .file( - "proc_macro_dep/src/lib.rs", - &format!( - r#" - extern crate proc_macro; - - use std::io::Read; - use std::net::TcpStream; - use proc_macro::TokenStream; - - #[proc_macro_derive(Noop)] - pub fn noop(_input: TokenStream) -> TokenStream {{ - let mut stream = TcpStream::connect("{}").unwrap(); - let mut v = Vec::new(); - stream.read_to_end(&mut v).unwrap(); - "".parse().unwrap() - }} - "#, - addr - ), - ) - .build(); - let root = p.root(); - - let t = thread::spawn(move || { - let socket = server.accept().unwrap().0; - let mut file = OpenOptions::new() - .write(true) - .append(true) - .open(root.join("root/src/lib.rs")) - .unwrap(); - writeln!(file, "// modified").expect("Failed to append to root sources"); - drop(file); - drop(socket); - drop(server.accept().unwrap()); - }); - - p.cargo("build") - .with_stderr( - "\ -[COMPILING] proc_macro_dep v0.1.0 ([..]/proc_macro_dep) -[COMPILING] root v0.1.0 ([..]/root) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -", - ) - .run(); - - p.cargo("build") - .with_stderr( - "\ -[COMPILING] root v0.1.0 ([..]/root) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -", - ) - .run(); - - t.join().ok().unwrap(); -} - #[test] fn dep_no_libs() { let foo = project() diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index a928bb16e95..81e7f1f32c6 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1,5 +1,7 @@ -use std::fs::{self, File}; +use std::fs::{self, File, OpenOptions}; use std::io::prelude::*; +use std::net::TcpListener; +use std::thread; use crate::support::paths::CargoPathExt; use crate::support::registry::Package; @@ -1309,3 +1311,109 @@ fn bust_patched_dep() { ) .run(); } + +#[test] +fn rebuild_on_mid_build_file_modification() { + let server = TcpListener::bind("127.0.0.1:0").unwrap(); + let addr = server.local_addr().unwrap(); + + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["root", "proc_macro_dep"] + "#, + ) + .file( + "root/Cargo.toml", + r#" + [project] + name = "root" + version = "0.1.0" + authors = [] + + [dependencies] + proc_macro_dep = { path = "../proc_macro_dep" } + "#, + ) + .file( + "root/src/lib.rs", + r#" + #[macro_use] + extern crate proc_macro_dep; + + #[derive(Noop)] + pub struct X; + "#, + ) + .file( + "proc_macro_dep/Cargo.toml", + r#" + [project] + name = "proc_macro_dep" + version = "0.1.0" + authors = [] + + [lib] + proc-macro = true + "#, + ) + .file( + "proc_macro_dep/src/lib.rs", + &format!( + r#" + extern crate proc_macro; + + use std::io::Read; + use std::net::TcpStream; + use proc_macro::TokenStream; + + #[proc_macro_derive(Noop)] + pub fn noop(_input: TokenStream) -> TokenStream {{ + let mut stream = TcpStream::connect("{}").unwrap(); + let mut v = Vec::new(); + stream.read_to_end(&mut v).unwrap(); + "".parse().unwrap() + }} + "#, + addr + ), + ) + .build(); + let root = p.root(); + + let t = thread::spawn(move || { + let socket = server.accept().unwrap().0; + let mut file = OpenOptions::new() + .write(true) + .append(true) + .open(root.join("root/src/lib.rs")) + .unwrap(); + writeln!(file, "// modified").expect("Failed to append to root sources"); + drop(file); + drop(socket); + drop(server.accept().unwrap()); + }); + + p.cargo("build") + .with_stderr( + "\ +[COMPILING] proc_macro_dep v0.1.0 ([..]/proc_macro_dep) +[COMPILING] root v0.1.0 ([..]/root) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); + + p.cargo("build") + .with_stderr( + "\ +[COMPILING] root v0.1.0 ([..]/root) +[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +", + ) + .run(); + + t.join().ok().unwrap(); +} From eba432324cbc82e914109b66c4eee9ba3b36e2a0 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Wed, 2 Jan 2019 15:42:51 -0500 Subject: [PATCH 5/7] Back touch the output instead of having a new important file. This still round trips through the file system just in case it is on a different clock. --- src/cargo/core/compiler/custom_build.rs | 7 ++++++- src/cargo/core/compiler/fingerprint.rs | 4 ++-- src/cargo/core/compiler/mod.rs | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index 391a2b7cf4b..dec3c57b169 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -332,10 +332,14 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes state.build_plan(invocation_name, cmd.clone(), Arc::new(Vec::new())); } else { state.running(&cmd); + // `invoked.timestamp` is used to get `FileTime::from_system_time(SystemTime::now());` + // using the exact clock that this file system is using. + let timestamp = output_file.with_file_name("invoked.timestamp"); paths::write( - &output_file.with_file_name("invoked.timestamp"), + ×tamp, b"This file has an mtime of when this build-script was started.", )?; + let timestamp = paths::mtime(×tamp)?; let output = if extra_verbose { let prefix = format!("[{} {}] ", id.name(), id.version()); state.capture_output(&cmd, Some(prefix), true) @@ -358,6 +362,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes // state informing what variables were discovered via our script as // well. paths::write(&output_file, &output.stdout)?; + filetime::set_file_times(output_file, timestamp, timestamp)?; paths::write(&err_file, &output.stderr)?; paths::write(&root_output_file, util::path2bytes(&script_out_dir)?)?; let parsed_output = diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 5fd44dd1e7f..484ca6c5e01 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -239,7 +239,7 @@ impl Fingerprint { for local in self.local.iter() { match *local { LocalFingerprint::MtimeBased(ref slot, ref path) => { - let path = root.join(&path.with_file_name("invoked.timestamp")); + let path = root.join(path); let mtime = paths::mtime(&path)?; *slot.0.lock().unwrap() = Some(mtime); } @@ -746,7 +746,7 @@ where I: IntoIterator, I::Item: AsRef, { - let mtime = match paths::mtime(&output.with_file_name("invoked.timestamp")) { + let mtime = match paths::mtime(output) { Ok(mtime) => mtime, Err(..) => return None, }; diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index bbb1f686b25..db86a60b9e2 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -292,10 +292,14 @@ fn rustc<'a, 'cfg>( } state.running(&rustc); + // `invoked.timestamp` is used to get `FileTime::from_system_time(SystemTime::now());` + // using the exact clock that this file system is using. + let timestamp = dep_info_loc.with_file_name("invoked.timestamp"); paths::write( - &dep_info_loc.with_file_name("invoked.timestamp"), + ×tamp, b"This file has an mtime of when rustc was started.", )?; + let timestamp = paths::mtime(×tamp)?; if json_messages { exec.exec_json( rustc, @@ -338,6 +342,7 @@ fn rustc<'a, 'cfg>( rustc_dep_info_loc.display() )) })?; + filetime::set_file_times(dep_info_loc, timestamp, timestamp)?; } Ok(()) From a87f50fb7c88d533285bad327c8ea2096f2c76dc Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Thu, 3 Jan 2019 11:31:45 -0500 Subject: [PATCH 6/7] make a helper function --- src/cargo/core/compiler/custom_build.rs | 9 +-------- src/cargo/core/compiler/mod.rs | 9 +-------- src/cargo/util/paths.rs | 12 ++++++++++++ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index dec3c57b169..c413ddcb66a 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -332,14 +332,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes state.build_plan(invocation_name, cmd.clone(), Arc::new(Vec::new())); } else { state.running(&cmd); - // `invoked.timestamp` is used to get `FileTime::from_system_time(SystemTime::now());` - // using the exact clock that this file system is using. - let timestamp = output_file.with_file_name("invoked.timestamp"); - paths::write( - ×tamp, - b"This file has an mtime of when this build-script was started.", - )?; - let timestamp = paths::mtime(×tamp)?; + let timestamp = paths::get_current_filesystem_time(&output_file)?; let output = if extra_verbose { let prefix = format!("[{} {}] ", id.name(), id.version()); state.capture_output(&cmd, Some(prefix), true) diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index db86a60b9e2..735b8f0e17c 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -292,14 +292,7 @@ fn rustc<'a, 'cfg>( } state.running(&rustc); - // `invoked.timestamp` is used to get `FileTime::from_system_time(SystemTime::now());` - // using the exact clock that this file system is using. - let timestamp = dep_info_loc.with_file_name("invoked.timestamp"); - paths::write( - ×tamp, - b"This file has an mtime of when rustc was started.", - )?; - let timestamp = paths::mtime(×tamp)?; + let timestamp = paths::get_current_filesystem_time(&dep_info_loc)?; if json_messages { exec.exec_json( rustc, diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 7cb6e8adc65..7ecd4160386 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -197,6 +197,18 @@ pub fn mtime(path: &Path) -> CargoResult { Ok(FileTime::from_last_modification_time(&meta)) } +/// get `FileTime::from_system_time(SystemTime::now());` using the exact clock that this file system is using. +pub fn get_current_filesystem_time(path: &Path) -> CargoResult { + // note that if `FileTime::from_system_time(SystemTime::now());` is determined to be sufficient, + // then this can be removed. + let timestamp = path.with_file_name("invoked.timestamp"); + write( + ×tamp, + b"This file has an mtime of when this was started.", + )?; + Ok(mtime(×tamp)?) +} + #[cfg(unix)] pub fn path2bytes(path: &Path) -> CargoResult<&[u8]> { use std::os::unix::prelude::*; From 40a0779181d2d95e2fba17b651eebc999fbe90e7 Mon Sep 17 00:00:00 2001 From: Eh2406 Date: Fri, 4 Jan 2019 15:47:22 -0500 Subject: [PATCH 7/7] back out 5919 --- src/cargo/core/compiler/fingerprint.rs | 12 +++++++----- tests/testsuite/freshness.rs | 4 ++++ tests/testsuite/path.rs | 2 ++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index 484ca6c5e01..0b34da51fd7 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -761,8 +761,9 @@ where } }; - // Note that equal mtimes are considered "stale". For filesystems with - // not much timestamp precision like 1s this is a conservative approximation + // TODO: fix #5918 + // Note that equal mtimes should be considered "stale". For filesystems with + // not much timestamp precision like 1s this is would be a conservative approximation // to handle the case where a file is modified within the same second after // a build starts. We want to make sure that incremental rebuilds pick that up! // @@ -774,10 +775,11 @@ where // a file is updated at most 10ms after a build starts then Cargo may not // pick up the build changes. // - // All in all, the equality check here is a conservative assumption that, + // All in all, an equality check here would be a conservative assumption that, // if equal, files were changed just after a previous build finished. - // It's hoped this doesn't cause too many issues in practice! - if mtime2 >= mtime { + // Unfortunately this became problematic when (in #6484) cargo switch to more accurately + // measuring the start time of builds. + if mtime2 > mtime { info!("stale: {} -- {} vs {}", path.display(), mtime2, mtime); true } else { diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 81e7f1f32c6..cab23c8e3b0 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -1283,6 +1283,9 @@ fn bust_patched_dep() { .build(); p.cargo("build").run(); + if is_coarse_mtime() { + sleep_ms(1000); + } File::create(&p.root().join("reg1new/src/lib.rs")).unwrap(); if is_coarse_mtime() { @@ -1385,6 +1388,7 @@ fn rebuild_on_mid_build_file_modification() { let t = thread::spawn(move || { let socket = server.accept().unwrap().0; + sleep_ms(1000); let mut file = OpenOptions::new() .write(true) .append(true) diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index 8e46a604b23..2c818c9cdf1 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -356,6 +356,7 @@ fn deep_dependencies_trigger_rebuild() { // // We base recompilation off mtime, so sleep for at least a second to ensure // that this write will change the mtime. + sleep_ms(1000); File::create(&p.root().join("baz/src/baz.rs")) .unwrap() .write_all(br#"pub fn baz() { println!("hello!"); }"#) @@ -372,6 +373,7 @@ fn deep_dependencies_trigger_rebuild() { .run(); // Make sure an update to bar doesn't trigger baz + sleep_ms(1000); File::create(&p.root().join("bar/src/bar.rs")) .unwrap() .write_all(