Skip to content

Commit

Permalink
Extract loading and comparison of compiletest outputs to new fn
Browse files Browse the repository at this point in the history
Moved into ```fn load_compare_outputs(&self, proc_res: &ProcRes, explicit_format: bool) -> usize```
  • Loading branch information
nathanwhit committed Aug 22, 2019
1 parent 54f80a5 commit 0c379df
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2934,44 +2934,49 @@ impl<'test> TestCx<'test> {
}
}

fn run_ui_test(&self) {
// if the user specified a format in the ui test
// print the output to the stderr file, otherwise extract
// the rendered error messages from json and print them
let explicit = self
.props
.compile_flags
.iter()
.any(|s| s.contains("--error-format"));
let proc_res = self.compile_test();
self.check_if_test_should_compile(&proc_res);

fn load_compare_outputs(&self, proc_res: &ProcRes, explicit_format: bool) -> usize {
let expected_stderr = self.load_expected_output(UI_STDERR);
let expected_stdout = self.load_expected_output(UI_STDOUT);
let expected_fixed = self.load_expected_output(UI_FIXED);

let normalized_stdout =
self.normalize_output(&proc_res.stdout, &self.props.normalize_stdout);

let stderr = if explicit {
let stderr = if explicit_format {
proc_res.stderr.clone()
} else {
json::extract_rendered(&proc_res.stderr)
};

let normalized_stderr = self.normalize_output(&stderr, &self.props.normalize_stderr);

let mut errors = 0;
if !self.props.dont_check_compiler_stdout {
errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout);
}
if !self.props.dont_check_compiler_stderr {
errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr);
}
errors
}

fn run_ui_test(&self) {
// if the user specified a format in the ui test
// print the output to the stderr file, otherwise extract
// the rendered error messages from json and print them
let explicit = self
.props
.compile_flags
.iter()
.any(|s| s.contains("--error-format"));
let proc_res = self.compile_test();
self.check_if_test_should_compile(&proc_res);

let expected_fixed = self.load_expected_output(UI_FIXED);

let modes_to_prune = vec![CompareMode::Nll];
self.prune_duplicate_outputs(&modes_to_prune);

let mut errors = self.load_compare_outputs(&proc_res, explicit);

if self.config.compare_mode.is_some() {
// don't test rustfix with nll right now
} else if self.config.rustfix_coverage {
Expand Down

0 comments on commit 0c379df

Please sign in to comment.