Skip to content

test: give each test run its own temporary root - #250

Merged
danfry1 merged 1 commit into
mainfrom
test/clean-temp-dirs
Oct 1, 2026
Merged

danfry1 merged 1 commit into
mainfrom
test/clean-temp-dirs

Conversation

@danfry1

@danfry1 danfry1 commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Summary

The unit and native test suites no longer leave scratch directories in the system temp directory.

Why

A single run of the unit suite left 64 entries in os.tmpdir(), from about 17 test files and the CLIs they spawn. The native suite left one more. A working machine had accumulated about 5,700 of them.

Changes

  • tests/support/temp-root.global.ts: a global setup that creates one root per run and points TMPDIR/TEMP/TMP at it, removing the root on teardown. Vitest runs global setup before starting workers, and os.tmpdir() reads those variables on every call, so workers and their child processes inherit the root without any per-test changes.
  • Configs: used by vitest.config.ts and tests-native/vitest.config.mts.

Notes for reviewers

A run of the unit suite left 64 entries in the system temp directory and the
native suite one more; a working machine had accumulated about 5,700. A global
setup now creates one root per run, points TMPDIR/TEMP/TMP at it before Vitest
starts workers (os.tmpdir() reads them on every call, and workers and their child
processes inherit them), and removes it when the run ends. The one remaining
directory per run is Vitest's own fetcher root, fixed upstream in 5.0.3.
@danfry1
danfry1 merged commit da8a749 into main Oct 1, 2026
33 checks passed
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