From 0d1a0540e46b504597497c1db3e2a4d0d89ee550 Mon Sep 17 00:00:00 2001 From: Raoul Strackx Date: Wed, 22 Mar 2023 13:04:55 +0100 Subject: [PATCH] Bugfix: avoid panic on invalid json output from libtest --- src/bootstrap/render_tests.rs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/render_tests.rs b/src/bootstrap/render_tests.rs index af2370d439e..19019ad2c08 100644 --- a/src/bootstrap/render_tests.rs +++ b/src/bootstrap/render_tests.rs @@ -100,18 +100,13 @@ fn render_all(mut self) { break; } - let trimmed = line.trim(); - if trimmed.starts_with("{") && trimmed.ends_with("}") { - self.render_message(match serde_json::from_str(&trimmed) { - Ok(parsed) => parsed, - Err(err) => { - panic!("failed to parse libtest json output; error: {err}, line: {line:?}"); - } - }); - } else { - // Handle non-JSON output, for example when --nocapture is passed. - print!("{line}"); - let _ = std::io::stdout().flush(); + match serde_json::from_str(&line) { + Ok(parsed) => self.render_message(parsed), + Err(_err) => { + // Handle non-JSON output, for example when --nocapture is passed. + print!("{line}"); + let _ = std::io::stdout().flush(); + } } } }