Skip to content

Commit

Permalink
revert "Update tools code"
Browse files Browse the repository at this point in the history
This reverts commit 1dc2015, which
switched to compiling the UI tests twice rather than extracting the
humanized output from a field in the JSON output.

A conflict in this revert commit had to be fixed manually where changes
introduced in rust-lang#48449 collide with the change we're trying to revert
(from rust-lang#48337).

This is in the matter of rust-lang#48550.

Conflicts:
	src/tools/compiletest/src/runtest.rs
  • Loading branch information
zackmdavis committed Feb 28, 2018
1 parent 0ff9872 commit 3ad06b3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 21 deletions.
19 changes: 19 additions & 0 deletions src/tools/compiletest/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ struct DiagnosticCode {
explanation: Option<String>,
}

pub fn extract_rendered(output: &str, proc_res: &ProcRes) -> String {
output.lines()
.filter_map(|line| if line.starts_with('{') {
match json::decode::<Diagnostic>(line) {
Ok(diagnostic) => diagnostic.rendered,
Err(error) => {
proc_res.fatal(Some(&format!("failed to decode compiler output as json: \
`{}`\noutput: {}\nline: {}",
error,
line,
output)));
}
}
} else {
None
})
.collect()
}

pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
output.lines()
.flat_map(|line| parse_line(file_name, line, output, proc_res))
Expand Down
42 changes: 21 additions & 21 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ impl<'test> TestCx<'test> {
}

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

Expand All @@ -267,7 +267,7 @@ impl<'test> TestCx<'test> {
}

fn run_rfail_test(&self) {
let proc_res = self.compile_test(&[]);
let proc_res = self.compile_test();

if !proc_res.status.success() {
self.fatal_proc_rec("compilation failed!", &proc_res);
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<'test> TestCx<'test> {
}

fn run_rpass_test(&self) {
let proc_res = self.compile_test(&[]);
let proc_res = self.compile_test();

if !proc_res.status.success() {
self.fatal_proc_rec("compilation failed!", &proc_res);
Expand All @@ -336,7 +336,7 @@ impl<'test> TestCx<'test> {
return self.run_rpass_test();
}

let mut proc_res = self.compile_test(&[]);
let mut proc_res = self.compile_test();

if !proc_res.status.success() {
self.fatal_proc_rec("compilation failed!", &proc_res);
Expand Down Expand Up @@ -578,7 +578,7 @@ impl<'test> TestCx<'test> {
let mut cmds = commands.join("\n");

// compile test file (it should have 'compile-flags:-g' in the header)
let compiler_run_result = self.compile_test(&[]);
let compiler_run_result = self.compile_test();
if !compiler_run_result.status.success() {
self.fatal_proc_rec("compilation failed!", &compiler_run_result);
}
Expand Down Expand Up @@ -835,7 +835,7 @@ impl<'test> TestCx<'test> {

fn run_debuginfo_lldb_test_no_opt(&self) {
// compile test file (it should have 'compile-flags:-g' in the header)
let compile_result = self.compile_test(&[]);
let compile_result = self.compile_test();
if !compile_result.status.success() {
self.fatal_proc_rec("compilation failed!", &compile_result);
}
Expand Down Expand Up @@ -1272,15 +1272,12 @@ impl<'test> TestCx<'test> {
}
}

fn compile_test(&self, extra_args: &[&'static str]) -> ProcRes {
fn compile_test(&self) -> ProcRes {
let mut rustc = self.make_compile_args(
&self.testpaths.file,
TargetLocation::ThisFile(self.make_exe_name()),
);

if !extra_args.is_empty() {
rustc.args(extra_args);
}
rustc.arg("-L").arg(&self.aux_output_dir_name());

match self.config.mode {
Expand Down Expand Up @@ -1628,14 +1625,13 @@ impl<'test> TestCx<'test> {
}
}
Ui => {
// In case no "--error-format" has been given in the test, we'll compile
// a first time to get the compiler's output then compile with
// "--error-format json" to check if all expected errors are actually there
// and that no new one appeared.
if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) {
rustc.args(&["--error-format", "json"]);
}
if !self.props.disable_ui_testing_normalization {
rustc.arg("-Zui-testing");
}
}
},
MirOpt => {
rustc.args(&[
"-Zdump-mir=all",
Expand Down Expand Up @@ -2114,7 +2110,7 @@ impl<'test> TestCx<'test> {
fn run_codegen_units_test(&self) {
assert!(self.revision.is_none(), "revisions not relevant here");

let proc_res = self.compile_test(&[]);
let proc_res = self.compile_test();

if !proc_res.status.success() {
self.fatal_proc_rec("compilation failed!", &proc_res);
Expand Down Expand Up @@ -2498,7 +2494,7 @@ impl<'test> TestCx<'test> {
.iter()
.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);
Expand All @@ -2510,8 +2506,13 @@ impl<'test> TestCx<'test> {
let normalized_stdout =
self.normalize_output(&proc_res.stdout, &self.props.normalize_stdout);

let normalized_stderr = self.normalize_output(&proc_res.stderr,
&self.props.normalize_stderr);
let stderr = if explicit {
proc_res.stderr.clone()
} else {
json::extract_rendered(&proc_res.stderr, &proc_res)
};

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

let mut errors = 0;
errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout);
Expand Down Expand Up @@ -2544,7 +2545,6 @@ impl<'test> TestCx<'test> {
}
}
if !explicit {
let proc_res = self.compile_test(&["--error-format", "json"]);
if !expected_errors.is_empty() || !proc_res.status.success() {
// "// error-pattern" comments
self.check_expected_errors(expected_errors, &proc_res);
Expand All @@ -2556,7 +2556,7 @@ impl<'test> TestCx<'test> {
}

fn run_mir_opt_test(&self) {
let proc_res = self.compile_test(&[]);
let proc_res = self.compile_test();

if !proc_res.status.success() {
self.fatal_proc_rec("compilation failed!", &proc_res);
Expand Down

0 comments on commit 3ad06b3

Please sign in to comment.