Commit 0983f67
fix(test): derive the prune cut from recorded timestamps, not a fixed 6s
`prune_older_than_keeps_the_newest_and_drops_only_the_old_tail` fails
intermittently on windows-latest with
assertion `left == right` failed: only the old tail should be removed
left: 3
right: 2
The fixture builds two old snapshots, sleeps 8s, then two new ones 1.1s
apart, and cuts at a hardcoded 6s. That assumes `repo.snapshot()` is fast:
`new:0` is only ~1.2s plus one git subprocess older than prune time, so on
a loaded Windows runner that subprocess alone carries it past the 6s line
and it is pruned with the old pair.
The existing fixture guard could not catch it — it asserts on `before[0]`
and `before[2]`, and `before[1]` is the entry that drifts.
The cut is now computed from the timestamps the repo actually recorded:
aim at the midpoint of the gap between the oldest survivor and the newest
victim, which leaves ~4s of slack in both directions instead of depending
on wall-clock luck. The gap itself is asserted first, so a fixture that
collapsed says so plainly rather than failing later as a count mismatch.
Behaviour under test is unchanged: two removed, `new:1` and `new:0`
survive. No production code is touched.
cargo clippy -p codewhale-tui --lib -> 0 errors
cargo test -p codewhale-tui --lib -- prune_older_than
-> test result: ok. 3 passed; 0 failed
Found when it failed the windows leg of Hmbown#5987, a PR containing zero Rust
files (TypeScript, CI config and .gitignore only), so it cannot have been
caused there.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D4rk4NXwyy6wmvii9Lp84P
Signed-off-by: CodeWhale Bot <bot@codewhale.net>1 parent 3f3aa9e commit 0983f67
1 file changed
Lines changed: 19 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1411 | 1411 | | |
1412 | 1412 | | |
1413 | 1413 | | |
1414 | | - | |
1415 | | - | |
1416 | | - | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
1417 | 1421 | | |
1418 | 1422 | | |
1419 | 1423 | | |
1420 | 1424 | | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
1421 | 1431 | | |
1422 | | - | |
1423 | | - | |
1424 | | - | |
1425 | | - | |
| 1432 | + | |
| 1433 | + | |
1426 | 1434 | | |
| 1435 | + | |
| 1436 | + | |
1427 | 1437 | | |
1428 | | - | |
1429 | | - | |
| 1438 | + | |
| 1439 | + | |
1430 | 1440 | | |
1431 | 1441 | | |
1432 | 1442 | | |
| |||
0 commit comments