Skip to content

Commit 17719dc

Browse files
committed
Don't dump diagnostics json if not absolutely necessary
1 parent e52b381 commit 17719dc

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/json.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,20 @@ struct DiagnosticCode {
6262
explanation: Option<String>,
6363
}
6464

65-
pub fn extract_rendered(output: &str, proc_res: &ProcRes) -> String {
65+
pub fn extract_rendered(output: &str) -> String {
6666
output
6767
.lines()
6868
.filter_map(|line| {
6969
if line.starts_with('{') {
7070
match serde_json::from_str::<Diagnostic>(line) {
7171
Ok(diagnostic) => diagnostic.rendered,
7272
Err(error) => {
73-
proc_res.fatal(Some(&format!(
73+
print!(
7474
"failed to decode compiler output as json: \
7575
`{}`\nline: {}\noutput: {}",
7676
error, line, output
77-
)));
77+
);
78+
panic!()
7879
}
7980
}
8081
} else {

src/runtest.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,7 +2760,7 @@ impl<'test> TestCx<'test> {
27602760
let stderr = if explicit {
27612761
proc_res.stderr.clone()
27622762
} else {
2763-
json::extract_rendered(&proc_res.stderr, &proc_res)
2763+
json::extract_rendered(&proc_res.stderr)
27642764
};
27652765

27662766
let normalized_stderr = self.normalize_output(&stderr, &self.props.normalize_stderr);
@@ -3377,7 +3377,9 @@ impl ProcRes {
33773377
{}\n\
33783378
------------------------------------------\n\
33793379
\n",
3380-
self.status, self.cmdline, self.stdout, self.stderr
3380+
self.status, self.cmdline,
3381+
json::extract_rendered(&self.stdout),
3382+
json::extract_rendered(&self.stderr),
33813383
);
33823384
panic!();
33833385
}

0 commit comments

Comments
 (0)