summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-01-12 02:30:23 +0100
committerGitHub <noreply@github.com>2023-01-12 02:30:23 +0100
commit692f9af14a6742cda7e24224eda6240e33d641d4 (patch)
tree5ba8ee68246efcfe39ff6aee2db921ae504e9a69
parent9d54765f3ebb1bb0d70338ae29bba9ee6aa55783 (diff)
fix: don't unwrap in test pipe handling logic (#17341)
Fixes #14746
-rw-r--r--cli/tools/test.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index 548ae2801..597666e73 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -1603,16 +1603,18 @@ impl TestEventSender {
| TestEvent::StepResult(_, _, _)
| TestEvent::UncaughtError(_, _)
) {
- self.flush_stdout_and_stderr();
+ self.flush_stdout_and_stderr()?;
}
self.sender.send(message)?;
Ok(())
}
- fn flush_stdout_and_stderr(&mut self) {
- self.stdout_writer.flush();
- self.stderr_writer.flush();
+ fn flush_stdout_and_stderr(&mut self) -> Result<(), AnyError> {
+ self.stdout_writer.flush()?;
+ self.stderr_writer.flush()?;
+
+ Ok(())
}
}
@@ -1643,7 +1645,7 @@ impl TestOutputPipe {
Self { writer, state }
}
- pub fn flush(&mut self) {
+ pub fn flush(&mut self) -> Result<(), AnyError> {
// We want to wake up the other thread and have it respond back
// that it's done clearing out its pipe before returning.
let (sender, receiver) = std::sync::mpsc::channel();
@@ -1653,10 +1655,12 @@ impl TestOutputPipe {
// Bit of a hack to send a zero width space in order to wake
// the thread up. It seems that sending zero bytes here does
// not work on windows.
- self.writer.write_all(ZERO_WIDTH_SPACE.as_bytes()).unwrap();
- self.writer.flush().unwrap();
+ self.writer.write_all(ZERO_WIDTH_SPACE.as_bytes())?;
+ self.writer.flush()?;
// ignore the error as it might have been picked up and closed
let _ = receiver.recv();
+
+ Ok(())
}
pub fn as_file(&self) -> std::fs::File {