Add --run flag to compiletest
This controls whether run-* tests actually get run.
This commit is contained in:
parent
bb491ed239
commit
051f9ec694
3 changed files with 26 additions and 5 deletions
|
@ -249,6 +249,9 @@ pub struct Config {
|
|||
/// Force the pass mode of a check/build/run-pass test to this mode.
|
||||
pub force_pass_mode: Option<PassMode>,
|
||||
|
||||
/// Explicitly enable or disable running.
|
||||
pub run: Option<bool>,
|
||||
|
||||
/// Write out a parseable log of tests that were run
|
||||
pub logfile: Option<PathBuf>,
|
||||
|
||||
|
|
|
@ -87,6 +87,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
"force {check,build,run}-pass tests to this mode.",
|
||||
"check | build | run",
|
||||
)
|
||||
.optopt("", "run", "whether to execute run-* tests", "auto | always | never")
|
||||
.optflag("", "ignored", "run tests marked as ignored")
|
||||
.optflag("", "exact", "filters match exactly")
|
||||
.optopt(
|
||||
|
@ -234,6 +235,12 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
mode.parse::<PassMode>()
|
||||
.unwrap_or_else(|_| panic!("unknown `--pass` option `{}` given", mode))
|
||||
}),
|
||||
run: matches.opt_str("run").and_then(|mode| match mode.as_str() {
|
||||
"auto" => None,
|
||||
"always" => Some(true),
|
||||
"never" => Some(false),
|
||||
_ => panic!("unknown `--run` option `{}` given", mode),
|
||||
}),
|
||||
logfile: matches.opt_str("logfile").map(|s| PathBuf::from(&s)),
|
||||
runtool: matches.opt_str("runtool"),
|
||||
host_rustcflags: matches.opt_str("host-rustcflags"),
|
||||
|
|
|
@ -317,6 +317,7 @@ enum TestOutput {
|
|||
enum WillExecute {
|
||||
Yes,
|
||||
No,
|
||||
Disabled,
|
||||
}
|
||||
|
||||
/// Should `--emit metadata` be used?
|
||||
|
@ -357,13 +358,22 @@ impl<'test> TestCx<'test> {
|
|||
}
|
||||
|
||||
fn should_run(&self, pm: Option<PassMode>) -> WillExecute {
|
||||
match self.config.mode {
|
||||
let test_should_run = match self.config.mode {
|
||||
Ui if pm == Some(PassMode::Run) || self.props.fail_mode == Some(FailMode::Run) => {
|
||||
WillExecute::Yes
|
||||
true
|
||||
}
|
||||
MirOpt if pm == Some(PassMode::Run) => WillExecute::Yes,
|
||||
Ui | MirOpt => WillExecute::No,
|
||||
MirOpt if pm == Some(PassMode::Run) => true,
|
||||
Ui | MirOpt => false,
|
||||
mode => panic!("unimplemented for mode {:?}", mode),
|
||||
};
|
||||
let enabled = self.config.run.unwrap_or_else(|| {
|
||||
// Auto-detect whether to run based on the platform.
|
||||
!self.config.target.ends_with("-fuchsia")
|
||||
});
|
||||
match (test_should_run, enabled) {
|
||||
(false, _) => WillExecute::No,
|
||||
(true, true) => WillExecute::Yes,
|
||||
(true, false) => WillExecute::Disabled,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1531,7 +1541,8 @@ impl<'test> TestCx<'test> {
|
|||
// Only use `make_exe_name` when the test ends up being executed.
|
||||
let output_file = match will_execute {
|
||||
WillExecute::Yes => TargetLocation::ThisFile(self.make_exe_name()),
|
||||
WillExecute::No => TargetLocation::ThisDirectory(self.output_base_dir()),
|
||||
WillExecute::No | WillExecute::Disabled =>
|
||||
TargetLocation::ThisDirectory(self.output_base_dir()),
|
||||
};
|
||||
|
||||
let allow_unused = match self.config.mode {
|
||||
|
|
Loading…
Reference in a new issue