Repository navigation
test: remove every temp dir the suite leaves behind (250 -> 0 per run) - #87
Merged
Merged
Conversation
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.
This was referenced Oct 24, 2026
Merged
|
🎉 This PR is included in version 0.9.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
One full
bun test ./test/run leaks 250osi-*directories into the system temp dir (measured at2123551). Nothing intest/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 getsin the
afterEachthat already restores the env.maxRetriesbecause an AV-scanning handle can briefly outlive a viewer'sstop();afterEach(notafterAll) so a crashed run costs one dir instead of its whole batch —lock.test.ts'safterAlldrain converted to match. Four files hoist abeforeEach-localconst rootto a moduleletso 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), soScripted.cleanup()and that suite'safterEachgain the same line.Verification (Windows, Bun 1.3.10 + 1.4.4)
bun x tsc --noEmitPer-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
mainand 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'spsi-e2e-*dirs (manual merge-gate only, separate harness).assisted by Qwen3-flash-next