Skip to content

Commit

Permalink
Enforce successful ui tests to have must-compile-successfully flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyip committed Dec 10, 2017
1 parent 2537a49 commit 5990b8b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/tools/compiletest/src/header.rs
Expand Up @@ -218,7 +218,7 @@ pub struct TestProps {
// testing harness and used when generating compilation
// arguments. (In particular, it propagates to the aux-builds.)
pub incremental_dir: Option<PathBuf>,
// Specifies that a cfail test must actually compile without errors.
// Specifies that a test must actually compile without errors.
pub must_compile_successfully: bool,
// rustdoc will test the output of the `--test` option
pub check_test_line_numbers_match: bool,
Expand Down
16 changes: 10 additions & 6 deletions src/tools/compiletest/src/runtest.rs
Expand Up @@ -147,23 +147,26 @@ impl<'test> TestCx<'test> {
assert!(self.revision.is_none(), "init_all invoked for a revision");
}

fn run_cfail_test(&self) {
let proc_res = self.compile_test();

fn check_if_test_should_compile(&self, proc_res: &ProcRes) {
if self.props.must_compile_successfully {
if !proc_res.status.success() {
self.fatal_proc_rec("test compilation failed although it shouldn't!", &proc_res);
self.fatal_proc_rec("test compilation failed although it shouldn't!", proc_res);
}
} else {
if proc_res.status.success() {
self.fatal_proc_rec(
&format!("{} test compiled successfully!", self.config.mode)[..],
&proc_res,
proc_res,
);
}

self.check_correct_failure_status(&proc_res);
self.check_correct_failure_status(proc_res);
}
}

fn run_cfail_test(&self) {
let proc_res = self.compile_test();
self.check_if_test_should_compile(&proc_res);

let output_to_check = self.get_output(&proc_res);
let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
Expand Down Expand Up @@ -2388,6 +2391,7 @@ impl<'test> TestCx<'test> {
.any(|s| s.contains("--error-format"));

let proc_res = self.compile_test();
self.check_if_test_should_compile(&proc_res);

let expected_stderr_path = self.expected_output_path(UI_STDERR);
let expected_stderr = self.load_expected_output(&expected_stderr_path);
Expand Down

0 comments on commit 5990b8b

Please sign in to comment.