Repository navigation
test: run each package's tests in a temp dir that is removed afterwards - #98
Conversation
A full test run left about 220 directories in the system temp dir: write, skill, read, glob, grep, bash and lsp test helpers create one per test and never remove it, and the tools package's ledger test leaves two. Turbo's strict env mode also dropped TMPDIR, so the tests wrote to /tmp even when TMPDIR pointed elsewhere. Every package's vitest config now runs scripts/vitest-temp-dir.ts as a global setup. It creates a fresh directory under the inherited temp dir, points TMPDIR at it for the run, and removes it when the run ends. That covers what the helpers create, what source code under test writes through os.tmpdir(), and caches dependencies keep there. core and tools get a vitest config for it. turbo.json passes TMPDIR through to tasks and lists the setup script as a global dependency.
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: eabecb49-b19a-4d40-9c72-3556f8139c4d) |
There was a problem hiding this comment.
This is an auto review done by revuto.
Revuto completed the review and found no evidence-backed concerns.
|
Verdict: ready to land. The counts reproduce exactly, the setup only ever removes its own run dir, and nothing blocking came up. Non-blocking
Checked and fine
What I ran
|
Problem
A full
turbo run testleaves about 220 directories in the temp dir. The write, read, glob, grep, bash and lsp test helpers and the skill tests create a directory per test and never remove it. The tools package's ledger test leaves two more. On top of that, turbo's strict env mode does not passTMPDIRto tasks, so the tests write to/tmpeven whenTMPDIRpoints somewhere else.Fix
scripts/vitest-temp-dir.tsis a vitest global setup. It creates a fresh directory under the temp dir the run inherited (TMPDIR, or the OS default), pointsTMPDIRat it while the tests run, and removes it when the run ends. Workers see it throughos.tmpdir(). No temp path is hardcoded.vitest.config.tslists it asglobalSetup.coreandtoolshad no vitest config and get one with only that setting, so their test discovery is unchanged.turbo.jsonpassesTMPDIRthrough to tasks (globalPassThroughEnv, which does not affect cache hashes) and lists the setup script inglobalDependencies, so editing it invalidates the cache.One setup per run, rather than cleanup in each helper, also catches what the code under test writes through
os.tmpdir()(for example the bash runtime dirs) and what dependencies cache there (theripgrepwasm file). Those land in the run dir and go with it.packages/lsp/test/spawnClient.test.tsis unchanged; it already removes its own dirs, and #95 changes it.Proof
Full
turbo run test --forcewithout harness-e2e (as in CI), withTMPDIRset to a fresh empty directory, and/tmplisted before and after:TMPDIRafter the run/tmpOn main the
TMPDIRcount is 0 only because turbo drops the variable and everything goes to/tmp. To show the variable now reaches the tests, a throwaway test incoreasserted onos.tmpdir()underturbo run test. It reported<TMPDIR>/agent-sh-test-XXXXXX, and that directory was gone after the run.Checks
pnpm test:dependencies,pnpm lint:harnessandturbo run build typecheck testwithout harness-e2e pass, 39 of 39 tasks. No changeset: only test configuration changes, nothing published.Note
Low Risk
Test and Turbo configuration only; no production or published package behavior changes.
Overview
Adds shared Vitest global setup (
scripts/vitest-temp-dir.ts) that creates anagent-sh-test-*directory under the inherited temp root, setsTMPDIRfor the run, and recursively deletes it on teardown so leaked test artifacts (helpers,os.tmpdir(), dependency caches) do not accumulate.Every package
vitest.config.tswires in that setup;coreandtoolsgain minimal configs for the same.turbo.jsonpassesTMPDIRinto test tasks viaglobalPassThroughEnvand treats the setup script as aglobalDependencyso cache invalidates when it changes.Reviewed by Cursor Bugbot for commit bc23e07. Configure here.