Skip to content

Commit 26aed43

Browse files
author
Jonathan Turner
committed
Plumb through more debug output for failing tests
1 parent fc5c437 commit 26aed43

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/tools/compiletest/src/json.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use errors::{Error, ErrorKind};
1212
use rustc_serialize::json;
1313
use std::str::FromStr;
1414
use std::path::Path;
15+
use runtest::{fatal_proc_rec, ProcRes};
1516

1617
// These structs are a subset of the ones found in
1718
// `syntax::errors::json`.
@@ -55,13 +56,13 @@ struct DiagnosticCode {
5556
explanation: Option<String>,
5657
}
5758

58-
pub fn parse_output(file_name: &str, output: &str) -> Vec<Error> {
59+
pub fn parse_output(file_name: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
5960
output.lines()
60-
.flat_map(|line| parse_line(file_name, line, output))
61+
.flat_map(|line| parse_line(file_name, line, output, proc_res))
6162
.collect()
6263
}
6364

64-
fn parse_line(file_name: &str, line: &str, output: &str) -> Vec<Error> {
65+
fn parse_line(file_name: &str, line: &str, output: &str, proc_res: &ProcRes) -> Vec<Error> {
6566
// The compiler sometimes intermingles non-JSON stuff into the
6667
// output. This hack just skips over such lines. Yuck.
6768
if line.chars().next() == Some('{') {
@@ -72,8 +73,9 @@ fn parse_line(file_name: &str, line: &str, output: &str) -> Vec<Error> {
7273
expected_errors
7374
}
7475
Err(error) => {
75-
panic!("failed to decode compiler output as json: `{}`\noutput: {}\nline: {}",
76-
error, line, output);
76+
fatal_proc_rec(None, &format!(
77+
"failed to decode compiler output as json: `{}`\noutput: {}\nline: {}",
78+
error, line, output), proc_res);
7779
}
7880
}
7981
} else {

src/tools/compiletest/src/runtest.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ fn check_expected_errors(revision: Option<&str>,
10191019
let expect_note = expected_errors.iter().any(|ee| ee.kind == Some(ErrorKind::Note));
10201020

10211021
// Parse the JSON output from the compiler and extract out the messages.
1022-
let actual_errors = json::parse_output(&file_name, &proc_res.stderr);
1022+
let actual_errors = json::parse_output(&file_name, &proc_res.stderr, &proc_res);
10231023
let mut unexpected = 0;
10241024
let mut not_found = 0;
10251025
let mut found = vec![false; expected_errors.len()];
@@ -1111,7 +1111,7 @@ struct ProcArgs {
11111111
args: Vec<String>,
11121112
}
11131113

1114-
struct ProcRes {
1114+
pub struct ProcRes {
11151115
status: Status,
11161116
stdout: String,
11171117
stderr: String,
@@ -1576,7 +1576,7 @@ fn fatal(revision: Option<&str>, err: &str) -> ! {
15761576
error(revision, err); panic!();
15771577
}
15781578

1579-
fn fatal_proc_rec(revision: Option<&str>, err: &str, proc_res: &ProcRes) -> ! {
1579+
pub fn fatal_proc_rec(revision: Option<&str>, err: &str, proc_res: &ProcRes) -> ! {
15801580
error(revision, err);
15811581
print!("\
15821582
status: {}\n\

0 commit comments

Comments
 (0)