From 7d4f8683b8a9f92b591566371475051ecaeb084a Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 12 Mar 2019 20:38:31 +0100 Subject: [PATCH] Don't dump diagnostics json if not absolutely necessary --- src/tools/compiletest/src/json.rs | 7 ++++--- src/tools/compiletest/src/runtest.rs | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/tools/compiletest/src/json.rs b/src/tools/compiletest/src/json.rs index 15d449260efa0..a14b50aa5877c 100644 --- a/src/tools/compiletest/src/json.rs +++ b/src/tools/compiletest/src/json.rs @@ -62,7 +62,7 @@ struct DiagnosticCode { explanation: Option, } -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::(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 { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 9f57e79bb4c73..b1b918803af50 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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!(); }