Skip to content

Commit fc5a742

Browse files
committed
[wip] separate out a test_crate_args fn
1 parent 41d7937 commit fc5a742

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/bootstrap/test.rs

+20-16
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,25 @@ impl Step for CrateLibrustc {
21082108
}
21092109
}
21102110

2111+
// Given a `cargo test` subcommand, pass it the appropriate test flags given a `builder`.
2112+
fn cargo_test_args(cargo: &mut Command, libtest_args: &[&str], _crates: &[&str], builder: &Builder<'_>) {
2113+
if !builder.fail_fast {
2114+
cargo.arg("--no-fail-fast");
2115+
}
2116+
match builder.doc_tests {
2117+
DocTests::Only => {
2118+
cargo.arg("--doc");
2119+
}
2120+
DocTests::No => {
2121+
cargo.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
2122+
}
2123+
DocTests::Yes => {}
2124+
}
2125+
2126+
cargo.arg("--").args(&builder.config.cmd.test_args()).args(libtest_args);
2127+
add_flags_and_try_run_tests(builder, cargo);
2128+
}
2129+
21112130
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
21122131
pub struct Crate {
21132132
pub compiler: Compiler,
@@ -2560,24 +2579,9 @@ impl Step for Bootstrap {
25602579
// https://github.com/rust-lang/rust/issues/49215
25612580
cmd.env("RUSTFLAGS", flags);
25622581
}
2563-
if !builder.fail_fast {
2564-
cmd.arg("--no-fail-fast");
2565-
}
2566-
match builder.doc_tests {
2567-
DocTests::Only => {
2568-
cmd.arg("--doc");
2569-
}
2570-
DocTests::No => {
2571-
cmd.args(&["--lib", "--bins", "--examples", "--tests", "--benches"]);
2572-
}
2573-
DocTests::Yes => {}
2574-
}
2575-
2576-
cmd.arg("--").args(&builder.config.cmd.test_args());
25772582
// rustbuild tests are racy on directory creation so just run them one at a time.
25782583
// Since there's not many this shouldn't be a problem.
2579-
cmd.arg("--test-threads=1");
2580-
add_flags_and_try_run_tests(builder, &mut cmd);
2584+
cargo_test_args(&mut cmd, &["--test-threads=1"], &[], builder);
25812585
}
25822586

25832587
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {

0 commit comments

Comments
 (0)