Skip to content

Commit 0d1a054

Browse files
committed
Bugfix: avoid panic on invalid json output from libtest
1 parent 9bdb488 commit 0d1a054

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/bootstrap/render_tests.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,13 @@ impl<'a> Renderer<'a> {
100100
break;
101101
}
102102

103-
let trimmed = line.trim();
104-
if trimmed.starts_with("{") && trimmed.ends_with("}") {
105-
self.render_message(match serde_json::from_str(&trimmed) {
106-
Ok(parsed) => parsed,
107-
Err(err) => {
108-
panic!("failed to parse libtest json output; error: {err}, line: {line:?}");
109-
}
110-
});
111-
} else {
112-
// Handle non-JSON output, for example when --nocapture is passed.
113-
print!("{line}");
114-
let _ = std::io::stdout().flush();
103+
match serde_json::from_str(&line) {
104+
Ok(parsed) => self.render_message(parsed),
105+
Err(_err) => {
106+
// Handle non-JSON output, for example when --nocapture is passed.
107+
print!("{line}");
108+
let _ = std::io::stdout().flush();
109+
}
115110
}
116111
}
117112
}

0 commit comments

Comments
 (0)