Skip to content

Commit

Permalink
Add needs-run-enabled directive for should-fail tests
Browse files Browse the repository at this point in the history
I was wary of doing any automatic disabling here, since should-fail
is how we test compiletest itself.
  • Loading branch information
tmandry committed Apr 30, 2021
1 parent e282fd0 commit f64c45a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/test/debuginfo/should-fail.rs
Expand Up @@ -2,6 +2,7 @@

// == Test [gdb|lldb]-[command|check] are parsed correctly ===
// should-fail
// needs-run-enabled
// compile-flags:-g

// === GDB TESTS ===================================================================================
Expand Down
1 change: 1 addition & 0 deletions src/test/ui/meta/revision-bad.rs
Expand Up @@ -4,6 +4,7 @@
// run-fail
// revisions: foo bar
// should-fail
// needs-run-enabled
//[foo] error-pattern:bar
//[bar] error-pattern:foo

Expand Down
9 changes: 9 additions & 0 deletions src/tools/compiletest/src/common.rs
Expand Up @@ -351,6 +351,15 @@ pub struct Config {
pub npm: Option<String>,
}

impl Config {
pub fn run_enabled(&self) -> bool {
self.run.unwrap_or_else(|| {
// Auto-detect whether to run based on the platform.
!self.target.ends_with("-fuchsia")
})
}
}

#[derive(Debug, Clone)]
pub struct TestPaths {
pub file: PathBuf, // e.g., compile-test/foo/bar/baz.rs
Expand Down
4 changes: 4 additions & 0 deletions src/tools/compiletest/src/header.rs
Expand Up @@ -85,6 +85,10 @@ impl EarlyProps {
props.ignore = true;
}

if !config.run_enabled() && config.parse_name_directive(ln, "needs-run-enabled") {
props.ignore = true;
}

if !rustc_has_sanitizer_support
&& config.parse_name_directive(ln, "needs-sanitizer-support")
{
Expand Down
6 changes: 1 addition & 5 deletions src/tools/compiletest/src/runtest.rs
Expand Up @@ -369,11 +369,7 @@ impl<'test> TestCx<'test> {
}

fn run_if_enabled(&self) -> WillExecute {
let enabled = self.config.run.unwrap_or_else(|| {
// Auto-detect whether to run based on the platform.
!self.config.target.ends_with("-fuchsia")
});
if enabled { WillExecute::Yes } else { WillExecute::Disabled }
if self.config.run_enabled() { WillExecute::Yes } else { WillExecute::Disabled }
}

fn should_run_successfully(&self, pm: Option<PassMode>) -> bool {
Expand Down

0 comments on commit f64c45a

Please sign in to comment.