about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-04-19 20:58:45 -0500
committerjyn <github@jyn.dev>2023-04-29 02:19:39 -0500
commitfc5a742b24539f4e3e62dffa005c6a927adb66b5 (patch)
tree5c1e20dc5534f35468b81a0e2e83eb29857d5c8f
parent41d79374930ba9db67467008fc318f5e8fd8b93d (diff)
downloadrust-fc5a742b24539f4e3e62dffa005c6a927adb66b5.tar.gz
rust-fc5a742b24539f4e3e62dffa005c6a927adb66b5.zip
[wip] separate out a test_crate_args fn
-rw-r--r--src/bootstrap/test.rs36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 7f843d1c7d2..e8804eb1d60 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -2108,6 +2108,25 @@ impl Step for CrateLibrustc {
     }
 }
 
+// Given a `cargo test` subcommand, pass it the appropriate test flags given a `builder`.
+fn cargo_test_args(cargo: &mut Command, libtest_args: &[&str], _crates: &[&str], builder: &Builder<'_>) {
+    if !builder.fail_fast {
+        cargo.arg("--no-fail-fast");
+    }
+    match builder.doc_tests {
+        DocTests::Only => {
+            cargo.arg("--doc");
+        }
+        DocTests::No => {
+            cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
+        }
+        DocTests::Yes => {}
+    }
+
+    cargo.arg("--").args(&builder.config.cmd.test_args()).args(libtest_args);
+    add_flags_and_try_run_tests(builder, cargo);
+}
+
 #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
 pub struct Crate {
     pub compiler: Compiler,
@@ -2560,24 +2579,9 @@ impl Step for Bootstrap {
             // https://github.com/rust-lang/rust/issues/49215
             cmd.env("RUSTFLAGS", flags);
         }
-        if !builder.fail_fast {
-            cmd.arg("--no-fail-fast");
-        }
-        match builder.doc_tests {
-            DocTests::Only => {
-                cmd.arg("--doc");
-            }
-            DocTests::No => {
-                cmd.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
-            }
-            DocTests::Yes => {}
-        }
-
-        cmd.arg("--").args(&builder.config.cmd.test_args());
         // rustbuild tests are racy on directory creation so just run them one at a time.
         // Since there's not many this shouldn't be a problem.
-        cmd.arg("--test-threads=1");
-        add_flags_and_try_run_tests(builder, &mut cmd);
+        cargo_test_args(&mut cmd, &["--test-threads=1"], &[], builder);
     }
 
     fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {