Skip to content

Commit

Permalink
Fix a potential hang in test child error reports
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Mar 17, 2022
1 parent fbe9125 commit 3287be5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions zebra-test/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,20 @@ impl ContextFrom<&TestStatus> for Report {
impl<T> ContextFrom<&mut TestChild<T>> for Report {
type Return = Report;

#[allow(clippy::print_stdout)]
fn context_from(mut self, source: &mut TestChild<T>) -> Self::Return {
self = self.section(source.cmd.clone().header("Command:"));

if let Ok(Some(status)) = source.child.try_wait() {
self = self.context_from(&status);
}

// Reading test child process output could hang if the child process is still running,
// so kill it first.
if let Some(child) = source.child.as_mut() {
let _ = child.kill();
}

let mut stdout_buf = String::new();
let mut stderr_buf = String::new();

Expand Down

0 comments on commit 3287be5

Please sign in to comment.