Skip to content

Commit f9a81e4

Browse files
committed
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.
1 parent 2f5e6bb commit f9a81e4

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/bootstrap/render_tests.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ impl<'a> Renderer<'a> {
8888
}
8989

9090
fn render_all(mut self) {
91-
let mut line = String::new();
91+
let mut line = Vec::new();
9292
loop {
9393
line.clear();
94-
match self.stdout.read_line(&mut line) {
94+
match self.stdout.read_until(b'\n', &mut line) {
9595
Ok(_) => {}
9696
Err(err) if err.kind() == std::io::ErrorKind::UnexpectedEof => break,
9797
Err(err) => panic!("failed to read output of test runner: {err}"),
@@ -100,12 +100,13 @@ impl<'a> Renderer<'a> {
100100
break;
101101
}
102102

103-
match serde_json::from_str(&line) {
103+
match serde_json::from_slice(&line) {
104104
Ok(parsed) => self.render_message(parsed),
105105
Err(_err) => {
106106
// Handle non-JSON output, for example when --nocapture is passed.
107-
print!("{line}");
108-
let _ = std::io::stdout().flush();
107+
let mut stdout = std::io::stdout();
108+
stdout.write_all(&line).unwrap();
109+
let _ = stdout.flush();
109110
}
110111
}
111112
}

0 commit comments

Comments
 (0)