Enforce successful ui tests to have must-compile-successfully flag.

This commit is contained in:
Tommy Ip 2017-12-10 17:11:48 +00:00
parent 2537a499c2
commit 5990b8b57c
2 changed files with 11 additions and 7 deletions

View File

@ -218,7 +218,7 @@ pub struct TestProps {
// testing harness and used when generating compilation // testing harness and used when generating compilation
// arguments. (In particular, it propagates to the aux-builds.) // arguments. (In particular, it propagates to the aux-builds.)
pub incremental_dir: Option<PathBuf>, 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, pub must_compile_successfully: bool,
// rustdoc will test the output of the `--test` option // rustdoc will test the output of the `--test` option
pub check_test_line_numbers_match: bool, pub check_test_line_numbers_match: bool,

View File

@ -147,23 +147,26 @@ impl<'test> TestCx<'test> {
assert!(self.revision.is_none(), "init_all invoked for a revision"); assert!(self.revision.is_none(), "init_all invoked for a revision");
} }
fn run_cfail_test(&self) { fn check_if_test_should_compile(&self, proc_res: &ProcRes) {
let proc_res = self.compile_test();
if self.props.must_compile_successfully { if self.props.must_compile_successfully {
if !proc_res.status.success() { 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 { } else {
if proc_res.status.success() { if proc_res.status.success() {
self.fatal_proc_rec( self.fatal_proc_rec(
&format!("{} test compiled successfully!", self.config.mode)[..], &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 output_to_check = self.get_output(&proc_res);
let expected_errors = errors::load_errors(&self.testpaths.file, self.revision); let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
@ -2388,6 +2391,7 @@ impl<'test> TestCx<'test> {
.any(|s| s.contains("--error-format")); .any(|s| s.contains("--error-format"));
let proc_res = self.compile_test(); 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_path = self.expected_output_path(UI_STDERR);
let expected_stderr = self.load_expected_output(&expected_stderr_path); let expected_stderr = self.load_expected_output(&expected_stderr_path);