Don't require the output from libtest to be valid UTF-8

On Windows this is sometimes not the case, for reasons I can't track down.

This works around the problem, although I'm not sure how to confirm we're not generating invalid
build metrics in this case.
This commit is contained in:
jyn 2023-06-04 09:13:54 -05:00
parent 2f5e6bb817
commit f9a81e4769

View File

@ -88,10 +88,10 @@ impl<'a> Renderer<'a> {
}
fn render_all(mut self) {
let mut line = String::new();
let mut line = Vec::new();
loop {
line.clear();
match self.stdout.read_line(&mut line) {
match self.stdout.read_until(b'\n', &mut line) {
Ok(_) => {}
Err(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => break,
Err(err) => panic!("failed to read output of test runner: {err}"),
@ -100,12 +100,13 @@ impl<'a> Renderer<'a> {
break;
}
match serde_json::from_str(&line) {
match serde_json::from_slice(&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();
let mut stdout = std::io::stdout();
stdout.write_all(&line).unwrap();
let _ = stdout.flush();
}
}
}