Add needs-run-enabled directive for should-fail tests

I was wary of doing any automatic disabling here, since should-fail
is how we test compiletest itself.
This commit is contained in:
Tyler Mandry 2021-04-29 01:02:07 +00:00
parent e282fd045a
commit f64c45a7d2
5 changed files with 16 additions and 5 deletions

View File

@ -2,6 +2,7 @@
// == Test [gdb|lldb]-[command|check] are parsed correctly ===
// should-fail
// needs-run-enabled
// compile-flags:-g
// === GDB TESTS ===================================================================================

View File

@ -4,6 +4,7 @@
// run-fail
// revisions: foo bar
// should-fail
// needs-run-enabled
//[foo] error-pattern:bar
//[bar] error-pattern:foo

View File

@ -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

View File

@ -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")
{

View File

@ -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 {