test(#110): stop bun test from leaving scratch dirs under tests/ - #125
Merged
Conversation
`bun test` left `tests/__tmp_intent_tests__/` populated and the empty
`tests/tmp/{cas-locking,locking-mp}/` parents behind, dirtying `git status`
after every run and letting the next run start from stale fixtures.
- tests/intent.test.ts: several describe blocks call setup() with no matching
afterEach, so add a file-level afterAll that removes both TMP_DIR and the
B15 fixture regardless of which block created them or whether a test threw.
- tests/cas-locking.test.ts, tests/locking-multiprocess.test.ts: each describe
already removed its own fixture, but nothing swept the shared parent. Add a
file-level afterAll that removes the subtree and rmdirs tests/tmp when empty.
- .gitignore: cover tests/tmp/ alongside tests/__tmp_*/ as a backstop for a run
that dies before afterAll fires.
- tests/scratch-hygiene.test.ts: functional guard — run the owning test files in
a child process and assert the scratch trees are gone on exit, plus assert the
gitignore backstop. All 3 fail without the fixes above.
Suite: 856 pass / 0 fail, clean `git status` after.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Owner
Author
|
🎉 This PR is included in version 4.4.15 🎉 The release is available on GitHub release 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.
Closes #110.
Problem
bun testleft scratch state in the working copy:tests/__tmp_intent_tests__/— populated witha.ts,b.ts,app.ts,utils.ts,package.json,tsconfig.json. Fourdescribeblocks intests/intent.test.tsregisterafterEach(cleanup), butparseIntent,generatePlan, andexecutePlan verification / rollback correctnesscallsetup()with no matching cleanup.tests/tmp/cas-locking/andtests/tmp/locking-mp/— eachdescriberemoved its own fixture directory, but nothing removed the shared parents, so the empty trees survived every run.Consequence:
git statuswas never clean after a test run, and the next run started from stale fixtures instead of a fresh tree.Fix
tests/intent.test.ts— file-levelafterAllremoving bothTMP_DIRand theB15fixture, so the sweep happens regardless of which block created the tree or whether a test threw partway through.B15's declaration is hoisted above the hook; its paths and the literal path assertions are unchanged.tests/cas-locking.test.ts,tests/locking-multiprocess.test.ts— file-levelafterAllthat removes the file's subtree andrmdirstests/tmpwhen it is empty (ignored when another file still owns it)..gitignore—tests/tmp/added next to the existingtests/__tmp_*/, as a backstop for a run killed beforeafterAllfires.Verification
tests/scratch-hygiene.test.ts(3 tests) is functional rather than static: it runstests/intent.test.tsandtests/cas-locking.test.tsin child processes and asserts the scratch trees are absent when the child exits, plus asserts the gitignore backstop.Falsification — with the three test files and
.gitignorestashed, all 3 fail; with the fixes, all 3 pass.Full suite: 856 pass / 0 fail, and
git status --porcelainis empty afterward (previously it was not).bun run lint:docspasses.Eval suite
No bench case. The bench harness models edit correctness (
correct/silent-corruption/false-refusal); this defect is test-harness hygiene with no HashPilot edit path involved, so there is nothing for a case to assert. The regression is pinned by the functional guard above instead.No
src/change, so no README/ARCHITECTURE update is required by the Docs Verify gate.🤖 Generated with Claude Code