Skip to content

Remove test temp folders when the test process exits - #220

Merged
BunsDev merged 3 commits into
mainfrom
test-tmp-cleanup
Oct 15, 2026
Merged

BunsDev merged 3 commits into
mainfrom
test-tmp-cleanup

Conversation

@BunsDev

@BunsDev BunsDev commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Unit and e2e tests created a fresh temporary home or repo for nearly every test and never removed it. By 2026-10-15, $TMPDIR held about 170,000 modex-repo-*, modex-home-*, modex-script-*, modex-desktop-* and modex-e2e-* folders (24 GB). The disk reached 100%, and builds and tests failed for every session on this Mac.

  • test/helpers.ts: tmpdir(), which gitRepo() and writeScript() also use, records each folder and removes it when the test process exits. node --test runs each file in its own process.
  • e2e/support.ts: seedHome() does the same for its home and repo when the Playwright worker exits. Relaunches within a test still reuse the same home.
  • MODEX_KEEP_TEST_TMP=1 keeps everything for debugging.
  • layout.test.ts's two direct mkdtemp calls now use the helper.

Verified by running the full unit suite with TMPDIR pointed at an empty folder. Before the layout change, 11 folders were left behind: 8 from native helper builds, 2 modex-ws-* (now fixed) and Node's compile cache. Before this change, every run left hundreds.

That run also had 9 terminal test failures. They came from the long scratch TMPDIR path, not this change: all terminal* tests pass with the normal TMPDIR (26 passed, 6 skipped). The layout tests and typecheck pass.

tmpdir() and the e2e seedHome() created a fresh home or repo for every
test and never removed it: by 2026-10-15 about 170,000 such folders
(24 GB) had filled the disk. Both now record what they create and
remove it when the process exits (node --test runs each file in its own
process; Playwright workers exit after their tests). Set
MODEX_KEEP_TEST_TMP=1 to keep them for debugging. The layout test's two
direct mkdtemp calls use the helper too. A full unit run now leaves
about nine folders, from native helper builds and Node's compile cache,
instead of hundreds.

Coven-Harness: Claude Code / claude-opus-5-5
@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
modex Ready Ready Preview Oct 15, 2026 2:44pm UTC

Request Review

@BunsDev
BunsDev merged commit bd6ff49 into main Oct 15, 2026
12 checks passed
@BunsDev
BunsDev deleted the test-tmp-cleanup branch October 15, 2026 15:09

This branch was successfully deployed

1 active deployment
Preview — 7c0317ab Deployed Oct 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant