diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-05-10 17:59:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-10 17:59:35 -0400 |
commit | e3f4b02f48c1e1b1e70cb9237126b9bc5d9720e3 (patch) | |
tree | b58d62c5620b51293557da76f0da37b05bdcc963 | |
parent | 75f373dd42c8d03941f0d71128b417ed0e2ffa06 (diff) |
fix: do not panic on `TestOutputPipe::flush` when receiver dropped (#14560)
-rw-r--r-- | cli/tools/test.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cli/tools/test.rs b/cli/tools/test.rs index 5395de6af..97507c536 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -1622,13 +1622,16 @@ impl TestOutputPipe { // 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(); - self.state.lock().replace(sender); + if let Some(sender) = self.state.lock().replace(sender) { + let _ = sender.send(()); // just in case + } // 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(); - receiver.recv().unwrap(); + // ignore the error as it might have been picked up and closed + let _ = receiver.recv(); } pub fn as_file(&self) -> std::fs::File { |