Skip to content

Commit 275e0af

Browse files
shengyfuCopilot
andcommitted
test: tolerate child exit during owned process cancellation
Recheck exit status if killing a previously-running child fails, preserving timeout diagnostics when the child won the race. Exercise repeat cancellation after reaping. Co-authored-by: Copilot App <[email protected]>
1 parent 390413f commit 275e0af

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎tgrep-cli/tests/shared_daemon/runtime.rs‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ impl Process {
3030
}
3131

3232
fn cancel(&mut self) {
33-
if self.child.try_wait().unwrap().is_none() {
34-
self.child.kill().unwrap();
33+
if self.child.try_wait().unwrap().is_none()
34+
&& let Err(error) = self.child.kill()
35+
{
36+
assert!(
37+
self.child.try_wait().unwrap().is_some(),
38+
"cannot cancel owned PID {}: {error}",
39+
self.child.id()
40+
);
3541
}
3642
self.child.wait().unwrap();
3743
}
@@ -285,6 +291,7 @@ fn runtime_sessions_recover_abandonment_restart_and_release_budgets() {
285291
.unwrap_err();
286292
assert!(timeout.contains("killed and reaped"), "{timeout}");
287293
assert!(retried.process.child.try_wait().unwrap().is_some());
294+
retried.process.cancel();
288295
assert_eq!(d.lookup(&f.b)["leases"], 1);
289296
let c = f.third(&f.revision);
290297
let c_journal = Session::persist(&f, &d, "replacement", &c, false);

0 commit comments

Comments
 (0)