Don't dump diagnostics json if not absolutely necessary

This commit is contained in:
Oliver Scherer 2019-03-12 20:38:31 +01:00
parent c26f6dbead
commit 7d4f8683b8
2 changed files with 8 additions and 5 deletions

View file

@ -62,7 +62,7 @@ struct DiagnosticCode {
explanation: Option<String>,
}
pub fn extract_rendered(output: &str, proc_res: &ProcRes) -> String {
pub fn extract_rendered(output: &str) -> String {
output
.lines()
.filter_map(|line| {
@ -70,11 +70,12 @@ pub fn extract_rendered(output: &str, proc_res: &ProcRes) -> String {
match serde_json::from_str::<Diagnostic>(line) {
Ok(diagnostic) => diagnostic.rendered,
Err(error) => {
proc_res.fatal(Some(&format!(
print!(
"failed to decode compiler output as json: \
`{}`\nline: {}\noutput: {}",
error, line, output
)));
);
panic!()
}
}
} else {

View file

@ -2760,7 +2760,7 @@ impl<'test> TestCx<'test> {
let stderr = if explicit {
proc_res.stderr.clone()
} else {
json::extract_rendered(&proc_res.stderr, &proc_res)
json::extract_rendered(&proc_res.stderr)
};
let normalized_stderr = self.normalize_output(&stderr, &self.props.normalize_stderr);
@ -3377,7 +3377,9 @@ impl ProcRes {
{}\n\
------------------------------------------\n\
\n",
self.status, self.cmdline, self.stdout, self.stderr
self.status, self.cmdline,
json::extract_rendered(&self.stdout),
json::extract_rendered(&self.stderr),
);
panic!();
}