summaryrefslogtreecommitdiff
path: root/test_util/src/builders.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test_util/src/builders.rs')
-rw-r--r--test_util/src/builders.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/test_util/src/builders.rs b/test_util/src/builders.rs
index 254490073..a5f192b73 100644
--- a/test_util/src/builders.rs
+++ b/test_util/src/builders.rs
@@ -455,6 +455,7 @@ pub struct TestCommandOutput {
}
impl Drop for TestCommandOutput {
+ // assert the output and exit code was asserted
fn drop(&mut self) {
fn panic_unasserted_output(text: &str) {
println!("OUTPUT\n{text}\nOUTPUT");
@@ -467,13 +468,6 @@ impl Drop for TestCommandOutput {
if std::thread::panicking() {
return;
}
- // force the caller to assert these
- if !*self.asserted_exit_code.borrow() && self.exit_code != Some(0) {
- panic!(
- "The non-zero exit code of the command was not asserted: {:?}",
- self.exit_code,
- )
- }
// either the combined output needs to be asserted or both stdout and stderr
if let Some(combined) = &self.combined {
@@ -489,6 +483,14 @@ impl Drop for TestCommandOutput {
panic_unasserted_output(stderr);
}
}
+
+ // now ensure the exit code was asserted
+ if !*self.asserted_exit_code.borrow() && self.exit_code != Some(0) {
+ panic!(
+ "The non-zero exit code of the command was not asserted: {:?}",
+ self.exit_code,
+ )
+ }
}
}