anthonyoteri / anthonyoteri/cargo-rigtest
Run teardown / a capture hook even when a test times out
- Dominant language
- Rust
- Stars
- 0
- Forks
- 0
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 8
Description
## Problem
When a `timeout` fires, the test subprocess is hard-killed and per-test **teardown does not run** (as documented). For a suite driving a shared external backend, a timed-out test can leave that backend in a bad state, cascading failures into every subsequent test. There's also no hook to capture context (logs/state) at the moment of failure or timeout.
## Proposal
1. On timeout, send a cancellation/grace signal and run the registered `ctx.teardown(...)` within a **bounded grace window** before the hard-kill.
2. An optional per-test **on-failure / on-timeout hook** (a closure) that runs to capture diagnostics and attach them to that case's report.
```rust
#[testcase(timeout = Duration::from_secs(30), teardown_grace = Duration::from_secs(5))]
async fn t(ctx: Arc) -> Result<(), rigtest::Error> { /* ... */ Ok(()) }
```
## Why
Guarantees cleanup so one slow/wedged test can't poison siblings that share a backend, and gives a capture point that actually runs when a test dies. Complements #42 (failure capsule) — that packages artifacts; this ensures teardown + a capture point run on timeout. Bounded grace so a wedged teardown can't itself hang.
Contributor guide
Assessment
This issue has not been assessed yet.