Skip to content

Commit 051f9ec

Browse files
committed
Add --run flag to compiletest
This controls whether run-* tests actually get run.
1 parent bb491ed commit 051f9ec

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

src/tools/compiletest/src/common.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,9 @@ pub struct Config {
249249
/// Force the pass mode of a check/build/run-pass test to this mode.
250250
pub force_pass_mode: Option<PassMode>,
251251

252+
/// Explicitly enable or disable running.
253+
pub run: Option<bool>,
254+
252255
/// Write out a parseable log of tests that were run
253256
pub logfile: Option<PathBuf>,
254257

src/tools/compiletest/src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
8787
"force {check,build,run}-pass tests to this mode.",
8888
"check | build | run",
8989
)
90+
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
9091
.optflag("", "ignored", "run tests marked as ignored")
9192
.optflag("", "exact", "filters match exactly")
9293
.optopt(
@@ -234,6 +235,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
234235
mode.parse::<PassMode>()
235236
.unwrap_or_else(|_| panic!("unknown `--pass` option `{}` given", mode))
236237
}),
238+
run: matches.opt_str("run").and_then(|mode| match mode.as_str() {
239+
"auto" => None,
240+
"always" => Some(true),
241+
"never" => Some(false),
242+
_ => panic!("unknown `--run` option `{}` given", mode),
243+
}),
237244
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
238245
runtool: matches.opt_str("runtool"),
239246
host_rustcflags: matches.opt_str("host-rustcflags"),

src/tools/compiletest/src/runtest.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ enum TestOutput {
317317
enum WillExecute {
318318
Yes,
319319
No,
320+
Disabled,
320321
}
321322

322323
/// Should `--emit metadata` be used?
@@ -357,13 +358,22 @@ impl<'test> TestCx<'test> {
357358
}
358359

359360
fn should_run(&self, pm: Option<PassMode>) -> WillExecute {
360-
match self.config.mode {
361+
let test_should_run = match self.config.mode {
361362
Ui if pm == Some(PassMode::Run) || self.props.fail_mode == Some(FailMode::Run) => {
362-
WillExecute::Yes
363+
true
363364
}
364-
MirOpt if pm == Some(PassMode::Run) => WillExecute::Yes,
365-
Ui | MirOpt => WillExecute::No,
365+
MirOpt if pm == Some(PassMode::Run) => true,
366+
Ui | MirOpt => false,
366367
mode => panic!("unimplemented for mode {:?}", mode),
368+
};
369+
let enabled = self.config.run.unwrap_or_else(|| {
370+
// Auto-detect whether to run based on the platform.
371+
!self.config.target.ends_with("-fuchsia")
372+
});
373+
match (test_should_run, enabled) {
374+
(false, _) => WillExecute::No,
375+
(true, true) => WillExecute::Yes,
376+
(true, false) => WillExecute::Disabled,
367377
}
368378
}
369379

@@ -1531,7 +1541,8 @@ impl<'test> TestCx<'test> {
15311541
// Only use `make_exe_name` when the test ends up being executed.
15321542
let output_file = match will_execute {
15331543
WillExecute::Yes => TargetLocation::ThisFile(self.make_exe_name()),
1534-
WillExecute::No => TargetLocation::ThisDirectory(self.output_base_dir()),
1544+
WillExecute::No | WillExecute::Disabled =>
1545+
TargetLocation::ThisDirectory(self.output_base_dir()),
15351546
};
15361547

15371548
let allow_unused = match self.config.mode {

0 commit comments

Comments
 (0)