diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs index 30b4c6cfc431..a7429e07d858 100644 --- a/src/bootstrap/src/core/config/tests.rs +++ b/src/bootstrap/src/core/config/tests.rs @@ -234,7 +234,7 @@ fn invalid_rust_optimize() { #[test] fn verify_file_integrity() { - let config = TestCtx::new().config("check").create_config(); + let config = TestCtx::new().config("check").no_dry_run().create_config(); let tempfile = config.tempdir().join(".tmp-test-file"); File::create(&tempfile).unwrap().write_all(b"dummy value").unwrap(); diff --git a/src/bootstrap/src/core/download.rs b/src/bootstrap/src/core/download.rs index ce3f49a35b9e..2f3c80559c0e 100644 --- a/src/bootstrap/src/core/download.rs +++ b/src/bootstrap/src/core/download.rs @@ -857,7 +857,7 @@ pub(crate) fn verify(exec_ctx: &ExecutionContext, path: &Path, expected: &str) - println!("verifying {}", path.display()); }); - if exec_ctx.dry_run() && !cfg!(test) { + if exec_ctx.dry_run() { return false; } diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 0561f343a8c1..e802c0214ddc 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -160,7 +160,7 @@ impl Drop for TimeIt { /// Symlinks two directories, using junctions on Windows and normal symlinks on /// Unix. pub fn symlink_dir(config: &Config, original: &Path, link: &Path) -> io::Result<()> { - if config.dry_run() && !cfg!(test) { + if config.dry_run() { return Ok(()); } let _ = fs::remove_dir_all(link); diff --git a/src/bootstrap/src/utils/helpers/tests.rs b/src/bootstrap/src/utils/helpers/tests.rs index ec99743d1ed8..676fe6cbd5fe 100644 --- a/src/bootstrap/src/utils/helpers/tests.rs +++ b/src/bootstrap/src/utils/helpers/tests.rs @@ -60,7 +60,7 @@ fn test_check_cfg_arg() { #[test] fn test_symlink_dir() { - let config = TestCtx::new().config("check").create_config(); + let config = TestCtx::new().config("check").no_dry_run().create_config(); let tempdir = config.tempdir().join(".tmp-dir"); let link_path = config.tempdir().join(".tmp-link"); diff --git a/src/bootstrap/src/utils/tests/mod.rs b/src/bootstrap/src/utils/tests/mod.rs index 0ccc8e1ebb8f..dc905969dcac 100644 --- a/src/bootstrap/src/utils/tests/mod.rs +++ b/src/bootstrap/src/utils/tests/mod.rs @@ -49,6 +49,7 @@ pub struct ConfigBuilder { args: Vec, directory: PathBuf, override_download_ci_llvm: bool, + dry_run: bool, } impl ConfigBuilder { @@ -57,6 +58,7 @@ impl ConfigBuilder { args: args.iter().copied().map(String::from).collect(), directory, override_download_ci_llvm: true, + dry_run: true, } } @@ -116,10 +118,16 @@ impl ConfigBuilder { self } - pub fn create_config(mut self) -> Config { - // Run in dry-check, otherwise the test would be too slow - self.args.push("--dry-run".to_string()); + pub fn no_dry_run(mut self) -> Self { + self.dry_run = false; + self + } + pub fn create_config(mut self) -> Config { + if self.dry_run { + // Run in dry-check, otherwise the test would be too slow + self.args.push("--dry-run".to_string()); + } // Ignore submodules self.args.push("--set".to_string()); self.args.push("build.submodules=false".to_string());