Skip to content

Commit f64c45a

Browse files
committed
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.
1 parent e282fd0 commit f64c45a

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

src/test/debuginfo/should-fail.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// == Test [gdb|lldb]-[command|check] are parsed correctly ===
44
// should-fail
5+
// needs-run-enabled
56
// compile-flags:-g
67

78
// === GDB TESTS ===================================================================================

src/test/ui/meta/revision-bad.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// run-fail
55
// revisions: foo bar
66
// should-fail
7+
// needs-run-enabled
78
//[foo] error-pattern:bar
89
//[bar] error-pattern:foo
910

src/tools/compiletest/src/common.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,15 @@ pub struct Config {
351351
pub npm: Option<String>,
352352
}
353353

354+
impl Config {
355+
pub fn run_enabled(&self) -> bool {
356+
self.run.unwrap_or_else(|| {
357+
// Auto-detect whether to run based on the platform.
358+
!self.target.ends_with("-fuchsia")
359+
})
360+
}
361+
}
362+
354363
#[derive(Debug, Clone)]
355364
pub struct TestPaths {
356365
pub file: PathBuf, // e.g., compile-test/foo/bar/baz.rs

src/tools/compiletest/src/header.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ impl EarlyProps {
8585
props.ignore = true;
8686
}
8787

88+
if !config.run_enabled() && config.parse_name_directive(ln, "needs-run-enabled") {
89+
props.ignore = true;
90+
}
91+
8892
if !rustc_has_sanitizer_support
8993
&& config.parse_name_directive(ln, "needs-sanitizer-support")
9094
{

src/tools/compiletest/src/runtest.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,7 @@ impl<'test> TestCx<'test> {
369369
}
370370

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

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

0 commit comments

Comments
 (0)