Skip to content

test: remove every temp dir the suite leaves behind (250 -> 0 per run) - #87

Merged
abogartz merged 2 commits into
abogartz:mainfrom
WhollyMindless:fix/test-tmp-cleanup
Oct 25, 2026
Merged

abogartz merged 2 commits into
abogartz:mainfrom
WhollyMindless:fix/test-tmp-cleanup

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

What

One full bun test ./test/ run leaks 250 osi-* directories into the system temp dir (measured at 2123551). Nothing in test/ ever removes a temp root. The repo already enforces the child half of this rule — test/helpers/temp-root.ts: "Guards, not care" — this PR adds the parent half.

How

One pattern, 27 files, all in test/: the per-file temp root gets

rmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 })

in the afterEach that already restores the env. maxRetries because an AV-scanning handle can briefly outlive a viewer's stop(); afterEach (not afterAll) so a crashed run costs one dir instead of its whole batch — lock.test.ts's afterAll drain converted to match. Four files hoist a beforeEach-local const root to a module let so the hook can see it. The two suites merged in #86 leak too (osi-script-* from the scripted helper, osi-cons-* from the consistency suite), so Scripted.cleanup() and that suite's afterEach gain the same line.

Verification (Windows, Bun 1.3.10 + 1.4.4)

before after
leaked dirs per full-suite run 250 0 (×2 runs each runtime)
full-suite failures 6–7 (resolver-trio on 1.3.10 + load-sensitive races) the identical set
bun x tsc --noEmit clean clean
biome warnings/infos baseline byte-identical

Per-file runs of every changed file leak 0; across my counted full-suite runs (both runtimes, failures included) leaks were 0 — a lone concurrency-flake leak shape seen in an earlier fix-tree sampling (AV-held dir surviving the ~100 ms retry when the test itself fails) reproduced identically on main and did not appear in these runs.

No semantics touched: no assertion, hook-order, or src/ change — the diff is hook additions, one import line per file, and the four hoists. Out of scope: the e2e harness's psi-e2e-* dirs (manual merge-gate only, separate harness).

assisted by Qwen3-flash-next

A full-suite run leaks every temp directory it creates: 250 osi-*
dirs measured under the system temp dir from one run at 0.8.9. The
repo already has the child-side half of this discipline
(test/helpers/temp-root.ts: "Guards, not care" — a spawned writer
refuses non-temp paths); this is the parent side.

Pattern, one shape everywhere: the file's temp root gets
`rmSync(root, { recursive: true, force: true, maxRetries: 5,
retryDelay: 20 })` in the afterEach that restores the env —
maxRetries because an AV-scanning handle can briefly outlive a
viewer's stop, and afterEach rather than afterAll so a crashed run
costs one dir, not its whole batch (lock.test.ts's afterAll drain
converted to match). Four files hoist a beforeEach-local `const root`
to a module `let` so the hook can see it; the scripted helper's
cleanup() and the consistency suite's root (both from abogartz#86) gain the
same, removing the osi-script-/osi-cons- leak those suites add.

Pass/fail is unchanged by construction — no assertion or hook-order
edits — and verified: the same failure set (the Bun 1.3.x resolver
trio plus load-sensitive cross-process races) before and after on
both Bun versions, and 0 leaked dirs after versus 250 before.
@abogartz
abogartz merged commit b465fc4 into abogartz:main Oct 25, 2026
3 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.9.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@WhollyMindless
WhollyMindless deleted the fix/test-tmp-cleanup branch October 26, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants