From d25688e6a739382f67e30792ce81a8e471e64f8e Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Tue, 3 May 2016 17:25:35 -0700 Subject: [PATCH 1/3] Print out the output line that fails json parsing --- src/tools/compiletest/src/json.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 3501b335205ed..4bc5b4f2f708e 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -72,7 +72,8 @@ fn parse_line(file_name: &str, line: &str) -> Vec { expected_errors } Err(error) => { - panic!("failed to decode compiler output as json: `{}`", error); + panic!("failed to decode compiler output as json: `{}` when parsing: {}", error, + line); } } } else { From fc5c4373f7f229e1381efcc50fbd13c6b65f0005 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 4 May 2016 08:06:28 -0700 Subject: [PATCH 2/3] Output the full output along with the line --- src/tools/compiletest/src/json.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 4bc5b4f2f708e..f1258096106f6 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -57,11 +57,11 @@ struct DiagnosticCode { pub fn parse_output(file_name: &str, output: &str) -> Vec { output.lines() - .flat_map(|line| parse_line(file_name, line)) + .flat_map(|line| parse_line(file_name, line, output)) .collect() } -fn parse_line(file_name: &str, line: &str) -> Vec { +fn parse_line(file_name: &str, line: &str, output: &str) -> Vec { // The compiler sometimes intermingles non-JSON stuff into the // output. This hack just skips over such lines. Yuck. if line.chars().next() == Some('{') { @@ -72,8 +72,8 @@ fn parse_line(file_name: &str, line: &str) -> Vec { expected_errors } Err(error) => { - panic!("failed to decode compiler output as json: `{}` when parsing: {}", error, - line); + panic!("failed to decode compiler output as json: `{}`\noutput: {}\nline: {}", + error, line, output); } } } else { From 26aed4392b245f899fa2ea3138276445c246bfd6 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Wed, 4 May 2016 13:29:26 -0700 Subject: [PATCH 3/3] Plumb through more debug output for failing tests --- src/tools/compiletest/src/json.rs | 12 +++++++----- src/tools/compiletest/src/runtest.rs | 6 +++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index f1258096106f6..665f304d69fa9 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::{fatal_proc_rec, ProcRes}; // These structs are a subset of the ones found in // `syntax::errors::json`. @@ -55,13 +56,13 @@ struct DiagnosticCode { explanation: Option, } -pub fn parse_output(file_name: &str, output: &str) -> Vec { +pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec { output.lines() - .flat_map(|line| parse_line(file_name, line, output)) + .flat_map(|line| parse_line(file_name, line, output, proc_res)) .collect() } -fn parse_line(file_name: &str, line: &str, output: &str) -> Vec { +fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec { // The compiler sometimes intermingles non-JSON stuff into the // output. This hack just skips over such lines. Yuck. if line.chars().next() == Some('{') { @@ -72,8 +73,9 @@ fn parse_line(file_name: &str, line: &str, output: &str) -> Vec { expected_errors } Err(error) => { - panic!("failed to decode compiler output as json: `{}`\noutput: {}\nline: {}", - error, line, output); + fatal_proc_rec(None, &format!( + "failed to decode compiler output as json: `{}`\noutput: {}\nline: {}", + error, line, output), proc_res); } } } else { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index fb296d57ebf8d..548c97be49d45 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1019,7 +1019,7 @@ fn check_expected_errors(revision: Option<&str>, 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()]; @@ -1111,7 +1111,7 @@ struct ProcArgs { args: Vec, } -struct ProcRes { +pub struct ProcRes { status: Status, stdout: String, stderr: String, @@ -1576,7 +1576,7 @@ fn fatal(revision: Option<&str>, err: &str) -> ! { error(revision, err); panic!(); } -fn fatal_proc_rec(revision: Option<&str>, err: &str, proc_res: &ProcRes) -> ! { +pub fn fatal_proc_rec(revision: Option<&str>, err: &str, proc_res: &ProcRes) -> ! { error(revision, err); print!("\ status: {}\n\