Skip to content

Commit 650dc01

Browse files
authored
Rollup merge of #111223 - jyn514:free-args, r=clubby789
Use `free-args` consistently in bootstrap Previously, this was only passed to miri and compiletest. Extended it to all other tests and binaries as well. cc https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Running.20a.20single.20doctest r? `@clubby789`
2 parents 17a6c08 + 0b6a79e commit 650dc01

File tree

4 files changed

+30
-28
lines changed

4 files changed

+30
-28
lines changed

src/bootstrap/config.rs

+22
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,28 @@ impl Config {
14421442
git
14431443
}
14441444

1445+
pub(crate) fn test_args(&self) -> Vec<&str> {
1446+
let mut test_args = match self.cmd {
1447+
Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => {
1448+
test_args.iter().flat_map(|s| s.split_whitespace()).collect()
1449+
}
1450+
_ => vec![],
1451+
};
1452+
test_args.extend(self.free_args.iter().map(|s| s.as_str()));
1453+
test_args
1454+
}
1455+
1456+
pub(crate) fn args(&self) -> Vec<&str> {
1457+
let mut args = match self.cmd {
1458+
Subcommand::Run { ref args, .. } => {
1459+
args.iter().flat_map(|s| s.split_whitespace()).collect()
1460+
}
1461+
_ => vec![],
1462+
};
1463+
args.extend(self.free_args.iter().map(|s| s.as_str()));
1464+
args
1465+
}
1466+
14451467
/// Bootstrap embeds a version number into the name of shared libraries it uploads in CI.
14461468
/// Return the version it would have used for the given commit.
14471469
pub(crate) fn artifact_version_part(&self, commit: &str) -> String {

src/bootstrap/flags.rs

-18
Original file line numberDiff line numberDiff line change
@@ -745,15 +745,6 @@ impl Subcommand {
745745
}
746746
}
747747

748-
pub fn test_args(&self) -> Vec<&str> {
749-
match *self {
750-
Subcommand::Test { ref test_args, .. } | Subcommand::Bench { ref test_args, .. } => {
751-
test_args.iter().flat_map(|s| s.split_whitespace()).collect()
752-
}
753-
_ => vec![],
754-
}
755-
}
756-
757748
pub fn rustc_args(&self) -> Vec<&str> {
758749
match *self {
759750
Subcommand::Test { ref rustc_args, .. } => {
@@ -763,15 +754,6 @@ impl Subcommand {
763754
}
764755
}
765756

766-
pub fn args(&self) -> Vec<&str> {
767-
match *self {
768-
Subcommand::Run { ref args, .. } => {
769-
args.iter().flat_map(|s| s.split_whitespace()).collect()
770-
}
771-
_ => vec![],
772-
}
773-
}
774-
775757
pub fn fail_fast(&self) -> bool {
776758
match *self {
777759
Subcommand::Test { fail_fast, .. } => fail_fast,

src/bootstrap/run.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl Step for BumpStage0 {
105105

106106
fn run(self, builder: &Builder<'_>) -> Self::Output {
107107
let mut cmd = builder.tool_cmd(Tool::BumpStage0);
108-
cmd.args(builder.config.cmd.args());
108+
cmd.args(builder.config.args());
109109
builder.run(&mut cmd);
110110
}
111111
}
@@ -182,8 +182,7 @@ impl Step for Miri {
182182
miri.add_rustc_lib_path(builder, compiler);
183183
// Forward arguments.
184184
miri.arg("--").arg("--target").arg(target.rustc_target_arg());
185-
miri.args(builder.config.cmd.args());
186-
miri.args(&builder.config.free_args);
185+
miri.args(builder.config.args());
187186

188187
// miri tests need to know about the stage sysroot
189188
miri.env("MIRI_SYSROOT", &miri_sysroot);

src/bootstrap/test.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl Step for Cargotest {
263263
builder,
264264
cmd.arg(&cargo)
265265
.arg(&out_dir)
266-
.args(builder.config.cmd.test_args())
266+
.args(builder.config.test_args())
267267
.env("RUSTC", builder.rustc(compiler))
268268
.env("RUSTDOC", builder.rustdoc(compiler)),
269269
);
@@ -634,7 +634,7 @@ impl Step for Miri {
634634
.arg(builder.src.join("src/tools/miri/test-cargo-miri/Cargo.toml"));
635635
cargo.arg("--target").arg(target.rustc_target_arg());
636636
cargo.arg("--tests"); // don't run doctests, they are too confused by the staging
637-
cargo.arg("--").args(builder.config.cmd.test_args());
637+
cargo.arg("--").args(builder.config.test_args());
638638

639639
// Tell `cargo miri` where to find things.
640640
cargo.env("MIRI_SYSROOT", &miri_sysroot);
@@ -1060,7 +1060,7 @@ impl Step for RustdocGUI {
10601060
}
10611061
}
10621062
}
1063-
for test_arg in builder.config.cmd.test_args() {
1063+
for test_arg in builder.config.test_args() {
10641064
command.arg(test_arg);
10651065
}
10661066
builder.run(&mut command);
@@ -1555,8 +1555,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
15551555
.filter_map(|p| util::is_valid_test_suite_arg(p, suite_path, builder))
15561556
.collect();
15571557

1558-
test_args.append(&mut builder.config.cmd.test_args());
1559-
test_args.extend(builder.config.free_args.iter().map(|s| s.as_str()));
1558+
test_args.append(&mut builder.config.test_args());
15601559

15611560
// On Windows, replace forward slashes in test-args by backslashes
15621561
// so the correct filters are passed to libtest
@@ -1962,7 +1961,7 @@ fn markdown_test(builder: &Builder<'_>, compiler: Compiler, markdown: &Path) ->
19621961
cmd.arg(markdown);
19631962
cmd.env("RUSTC_BOOTSTRAP", "1");
19641963

1965-
let test_args = builder.config.cmd.test_args().join(" ");
1964+
let test_args = builder.config.test_args().join(" ");
19661965
cmd.arg("--test-args").arg(test_args);
19671966

19681967
if builder.config.verbose_tests {
@@ -2099,7 +2098,7 @@ fn prepare_cargo_test(
20992098
cargo.arg("-p").arg(krate);
21002099
}
21012100

2102-
cargo.arg("--").args(&builder.config.cmd.test_args()).args(libtest_args);
2101+
cargo.arg("--").args(&builder.config.test_args()).args(libtest_args);
21032102
if !builder.config.verbose_tests {
21042103
cargo.arg("--quiet");
21052104
}

0 commit comments

Comments
 (0)