diff options
| author | bors <bors@rust-lang.org> | 2016-05-18 21:19:07 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2016-05-18 21:19:07 -0700 |
| commit | 0c5d651d0bb9e0471795bd743c8ecfd8f9a89844 (patch) | |
| tree | 21cd95b19248dbff4d36634c6922fcb40463e765 /src/tools/compiletest | |
| parent | 9c6904ca1e4ab95f6c48973dea718326735ad564 (diff) | |
| parent | b0a317dc6f8f9ecc973645f2d00f304f96eaf8b8 (diff) | |
Auto merge of #33688 - jonathandturner:fix_old_school, r=nikomatsakis
Fix for old school error issues, improvements to new school This PR: * Fixes some old school error issues, specifically #33559, #33543, #33366 * Improves wording borrowck errors with match patterns * De-emphasize multi-line spans, so we don't color the single source character when we're trying to say "span starts here" * Rollup of #33392 (which should help fix #33390) r? @nikomatsakis
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/json.rs | 11 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 43 |
2 files changed, 33 insertions, 21 deletions
diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 3501b335205..84b78547ab9 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -12,6 +12,7 @@ use errors::{Error, ErrorKind}; use rustc_serialize::json; use std::str::FromStr; use std::path::Path; +use runtest::{ProcRes}; // These structs are a subset of the ones found in // `syntax::errors::json`. @@ -55,13 +56,13 @@ struct DiagnosticCode { explanation: Option<String>, } -pub fn parse_output(file_name: &str, output: &str) -> Vec<Error> { +pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> { output.lines() - .flat_map(|line| parse_line(file_name, line)) + .flat_map(|line| parse_line(file_name, line, output, proc_res)) .collect() } -fn parse_line(file_name: &str, line: &str) -> Vec<Error> { +fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> { // The compiler sometimes intermingles non-JSON stuff into the // output. This hack just skips over such lines. Yuck. if line.chars().next() == Some('{') { @@ -72,7 +73,9 @@ fn parse_line(file_name: &str, line: &str) -> Vec<Error> { expected_errors } Err(error) => { - panic!("failed to decode compiler output as json: `{}`", error); + proc_res.fatal(Some(&format!( + "failed to decode compiler output as json: `{}`\noutput: {}\nline: {}", + error, line, output))); } } } else { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index f89ff6b3849..e6dc3a9d360 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1003,7 +1003,7 @@ actual:\n\ let expect_note = expected_errors.iter().any(|ee| ee.kind == Some(ErrorKind::Note)); // Parse the JSON output from the compiler and extract out the messages. - let actual_errors = json::parse_output(&file_name, &proc_res.stderr); + let actual_errors = json::parse_output(&file_name, &proc_res.stderr, &proc_res); let mut unexpected = 0; let mut not_found = 0; let mut found = vec![false; expected_errors.len()]; @@ -1547,21 +1547,7 @@ actual:\n\ fn fatal_proc_rec(&self, err: &str, proc_res: &ProcRes) -> ! { self.error(err); - print!("\ - status: {}\n\ - command: {}\n\ - stdout:\n\ - ------------------------------------------\n\ - {}\n\ - ------------------------------------------\n\ - stderr:\n\ - ------------------------------------------\n\ - {}\n\ - ------------------------------------------\n\ - \n", - proc_res.status, proc_res.cmdline, proc_res.stdout, - proc_res.stderr); - panic!(); + proc_res.fatal(None); } fn _arm_exec_compiled_test(&self, env: Vec<(String, String)>) -> ProcRes { @@ -2211,7 +2197,7 @@ struct ProcArgs { args: Vec<String>, } -struct ProcRes { +pub struct ProcRes { status: Status, stdout: String, stderr: String, @@ -2223,6 +2209,29 @@ enum Status { Normal(ExitStatus), } +impl ProcRes { + pub fn fatal(&self, err: Option<&str>) -> ! { + if let Some(e) = err { + println!("\nerror: {}", e); + } + print!("\ + status: {}\n\ + command: {}\n\ + stdout:\n\ + ------------------------------------------\n\ + {}\n\ + ------------------------------------------\n\ + stderr:\n\ + ------------------------------------------\n\ + {}\n\ + ------------------------------------------\n\ + \n", + self.status, self.cmdline, self.stdout, + self.stderr); + panic!(); + } +} + impl Status { fn code(&self) -> Option<i32> { match *self { |
