Skip to content

Commit

Permalink
Skip node2.is_running() on Windows
Browse files Browse the repository at this point in the history
`node2.is_running()` can return `true` on Windows, even though `node2`
has logged a panic. This cleanup code only runs if `node2` fails to panic
and exit as expected. So it's ok for us to skip it.

See #1781 for details.
  • Loading branch information
teor2345 committed Feb 19, 2021
1 parent a6b8ffb commit d48ecb2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions zebra-test/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ impl<T> TestChild<T> {
}

/// Is this process currently running?
///
/// ## BUGS
///
/// On Windows, this function can return `true` for processes that have
/// panicked. See #1781.
pub fn is_running(&mut self) -> bool {
matches!(self.child.try_wait(), Ok(None))
}
Expand Down
12 changes: 9 additions & 3 deletions zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,12 +1231,18 @@ where
let output1 = node1.wait_with_output();
let (output1, mut node2) = node2.kill_on_error(output1)?;

// node2 should have panicked due to a conflict. Kill it here
// anyway, so it doesn't outlive the test on error.
// node2 should have panicked due to a conflict. Kill it here anyway, so it
// doesn't outlive the test on error.
//
// This code doesn't work on Windows. It's cleanup code that only runs when
// node2 doesn't panic as expected. So it's ok to skip it. See #1781.
#[cfg(unix)]
if node2.is_running() {
use color_eyre::eyre::eyre;
return node2
.kill_on_error::<(), _>(Err(eyre!("conflicted node2 did not panic")))
.kill_on_error::<(), _>(Err(eyre!(
"conflicted node2 was still running, but the test expected a panic"
)))
.context_from(&output1)
.map(|_| ());
}
Expand Down

0 comments on commit d48ecb2

Please sign in to comment.