Skip to content

Commit 76b12bd

Browse files
committed
Support run-fail ui tests
1 parent 488381c commit 76b12bd

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

src/tools/compiletest/src/common.rs

+2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub enum PassMode {
100100
Check,
101101
Build,
102102
Run,
103+
RunFail,
103104
}
104105

105106
impl FromStr for PassMode {
@@ -120,6 +121,7 @@ impl fmt::Display for PassMode {
120121
PassMode::Check => "check",
121122
PassMode::Build => "build",
122123
PassMode::Run => "run",
124+
PassMode::RunFail => "run-fail",
123125
};
124126
fmt::Display::fmt(s, f)
125127
}

src/tools/compiletest/src/header.rs

+5
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ impl TestProps {
610610
panic!("`run-pass` header is only supported in UI tests")
611611
}
612612
Some(PassMode::Run)
613+
} else if config.parse_name_directive(ln, "run-fail") {
614+
if config.mode != Mode::Ui {
615+
panic!("`run-fail` header is only supported in UI tests")
616+
}
617+
Some(PassMode::RunFail)
613618
} else {
614619
None
615620
};

src/tools/compiletest/src/runtest.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ impl<'test> TestCx<'test> {
326326
self.props.pass_mode(self.config)
327327
}
328328

329+
fn should_run(&self) -> bool {
330+
let pass_mode = self.pass_mode();
331+
match self.config.mode {
332+
Ui => pass_mode == Some(PassMode::Run) || pass_mode == Some(PassMode::RunFail),
333+
mode => panic!("unimplemented for mode {:?}", mode),
334+
}
335+
}
336+
329337
fn should_run_successfully(&self) -> bool {
330338
let pass_mode = self.pass_mode();
331339
match self.config.mode {
@@ -1534,7 +1542,7 @@ impl<'test> TestCx<'test> {
15341542
fn compile_test(&self) -> ProcRes {
15351543
// Only use `make_exe_name` when the test ends up being executed.
15361544
let will_execute = match self.config.mode {
1537-
Ui => self.should_run_successfully(),
1545+
Ui => self.should_run(),
15381546
Incremental => self.revision.unwrap().starts_with("r"),
15391547
RunFail | RunPassValgrind | MirOpt |
15401548
DebugInfoCdb | DebugInfoGdbLldb | DebugInfoGdb | DebugInfoLldb => true,
@@ -3107,7 +3115,7 @@ impl<'test> TestCx<'test> {
31073115

31083116
let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
31093117

3110-
if self.should_run_successfully() {
3118+
if self.should_run() {
31113119
let proc_res = self.exec_compiled_test();
31123120
let run_output_errors = if self.props.check_run_results {
31133121
self.load_compare_outputs(&proc_res, TestOutput::Run, explicit)
@@ -3120,8 +3128,14 @@ impl<'test> TestCx<'test> {
31203128
&proc_res,
31213129
);
31223130
}
3123-
if !proc_res.status.success() {
3124-
self.fatal_proc_rec("test run failed!", &proc_res);
3131+
if self.should_run_successfully() {
3132+
if !proc_res.status.success() {
3133+
self.fatal_proc_rec("test run failed!", &proc_res);
3134+
}
3135+
} else {
3136+
if proc_res.status.success() {
3137+
self.fatal_proc_rec("test run succeeded!", &proc_res);
3138+
}
31253139
}
31263140
}
31273141

0 commit comments

Comments
 (0)