about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbit-aloo <sshourya17@gmail.com>2025-09-21 19:34:49 +0530
committerbit-aloo <sshourya17@gmail.com>2025-09-21 20:56:13 +0530
commit671aabd4eb1a56a09b989abc021bee32750ee59b (patch)
tree79d38923e891d885c0da73f564ea2f5aa329f0d4 /src/bootstrap
parent9189bf79d43dd162858bc58d64c6c99da7ca0add (diff)
downloadrust-671aabd4eb1a56a09b989abc021bee32750ee59b.tar.gz
rust-671aabd4eb1a56a09b989abc021bee32750ee59b.zip
add dry_run flag in config builder and remove runtime test hacks
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/core/config/tests.rs2
-rw-r--r--src/bootstrap/src/core/download.rs2
-rw-r--r--src/bootstrap/src/utils/helpers.rs2
-rw-r--r--src/bootstrap/src/utils/helpers/tests.rs2
-rw-r--r--src/bootstrap/src/utils/tests/mod.rs14
5 files changed, 15 insertions, 7 deletions
diff --git a/src/bootstrap/src/core/config/tests.rs b/src/bootstrap/src/core/config/tests.rs
index 30b4c6cfc43..a7429e07d85 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 ce3f49a35b9..2f3c80559c0 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 0561f343a8c..e802c0214dd 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 ec99743d1ed..676fe6cbd5f 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 0ccc8e1ebb8..dc905969dca 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<String>,
     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());