Skip to content

Commit db41f1e

Browse files
committed
Add rustc-args option to test runner
1 parent 44afd76 commit db41f1e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/bootstrap/check.rs

+1
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ impl Step for Compiletest {
750750
flags.push("-g".to_string());
751751
}
752752
flags.push("-Zmiri -Zunstable-options".to_string());
753+
flags.push(build.config.cmd.rustc_args().join(" "));
753754

754755
if let Some(linker) = build.linker(target) {
755756
cmd.arg("--linker").arg(linker);

src/bootstrap/flags.rs

+17
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub enum Subcommand {
5454
Test {
5555
paths: Vec<PathBuf>,
5656
test_args: Vec<String>,
57+
rustc_args: Vec<String>,
5758
fail_fast: bool,
5859
},
5960
Bench {
@@ -150,6 +151,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`");
150151
"test" => {
151152
opts.optflag("", "no-fail-fast", "Run all tests regardless of failure");
152153
opts.optmulti("", "test-args", "extra arguments", "ARGS");
154+
opts.optmulti(
155+
"",
156+
"rustc-args",
157+
"extra options to pass the compiler when running tests",
158+
"ARGS",
159+
);
153160
},
154161
"bench" => { opts.optmulti("", "test-args", "extra arguments", "ARGS"); },
155162
"clean" => { opts.optflag("", "all", "clean all build artifacts"); },
@@ -283,6 +290,7 @@ Arguments:
283290
Subcommand::Test {
284291
paths,
285292
test_args: matches.opt_strs("test-args"),
293+
rustc_args: matches.opt_strs("rustc-args"),
286294
fail_fast: !matches.opt_present("no-fail-fast"),
287295
}
288296
}
@@ -362,6 +370,15 @@ impl Subcommand {
362370
}
363371
}
364372

373+
pub fn rustc_args(&self) -> Vec<&str> {
374+
match *self {
375+
Subcommand::Test { ref rustc_args, .. } => {
376+
rustc_args.iter().flat_map(|s| s.split_whitespace()).collect()
377+
}
378+
_ => Vec::new(),
379+
}
380+
}
381+
365382
pub fn fail_fast(&self) -> bool {
366383
match *self {
367384
Subcommand::Test { fail_fast, .. } => fail_fast,

0 commit comments

Comments
 (0)