Skip to content

Commit e4fa2d8

Browse files
test(picker/summary): sleep between writes to avoid mtime tick collision (#2433)
## Problem `test_cache_roundtrip_and_prune_on_write` flaked on PR #2429's `code-coverage` job ([logs](https://github.com/max-sixty/worktrunk/actions/runs/24975304781/job/73126010174)) — the assertion that `deadbeef` was pruned after writing `cafebabe` failed, then a rerun passed. Root cause: `sweep_lru` (`src/cache.rs:126`) sorts entries by file mtime to pick the eviction victim. The test wrote `deadbeef` and `cafebabe` back-to-back with no delay; on filesystems with coarse mtime resolution both files can share a tick, making eviction order nondeterministic and sometimes pruning the newer entry instead. ## Solution Add a 10 ms sleep between the two writes — the same gap `test_sweep_lru_trims_oldest_entries` (`src/cache.rs:319-322`) already uses for the same reason. ## Testing Targeted test passes locally; the broader `commands::picker::summary::tests` and `cache::tests` modules still pass. --- Closes #2432 — automated triage Co-authored-by: worktrunk-bot <254187624+worktrunk-bot@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 76c8371 commit e4fa2d8

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/commands/picker/summary.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ mod tests {
142142
// Different hash for the same branch is a miss (content-addressed).
143143
assert!(CachedSummary::read(&repo, branch, "cafebabe").is_none());
144144

145+
// sweep_lru picks the eviction victim by file mtime; on filesystems
146+
// with coarse mtime resolution, back-to-back writes can share a tick
147+
// and the order becomes nondeterministic. Match the gap used in
148+
// test_sweep_lru_trims_oldest_entries.
149+
std::thread::sleep(std::time::Duration::from_millis(10));
150+
145151
// Writing a second hash for the same branch prunes the old one.
146152
let second = CachedSummary {
147153
summary: "Refactor tests".to_string(),

0 commit comments

Comments
 (0)