Skip to content

Commit 8be5bf9

Browse files
committed
Clean test failure if child isn't terminated properly
1 parent 0177193 commit 8be5bf9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tests/cli.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,11 +1088,17 @@ fn interrupt_caught_and_kills_children() {
10881088
child.terminate().expect("terminate child");
10891089

10901090
println!("Wait for cargo-mutants to exit...");
1091-
let exit_status = child
1092-
.wait_timeout(Duration::from_secs(4))
1093-
.expect("wait for child")
1094-
.expect("child exited");
1095-
println!("Child exited with status: {:?}", exit_status);
1091+
match child.wait_timeout(Duration::from_secs(4)) {
1092+
Err(e) => panic!("failed to wait for child: {}", e),
1093+
Ok(None) => {
1094+
println!("child did not exit after interrupt");
1095+
child.kill().expect("kill child");
1096+
child.wait().expect("wait for child after kill");
1097+
}
1098+
Ok(Some(status)) => {
1099+
println!("cargo-mutants exited with status: {status:?}");
1100+
}
1101+
}
10961102

10971103
let mut stdout = String::new();
10981104
child

0 commit comments

Comments
 (0)