Repository navigation
test(global): a test run owns a temporary folder of its own, which its teardown checks and removes - #284
Merged
Conversation
…r it wrote the file in The test of an unquoted compact JSON line in an env file made an api-keys- folder under the temporary directory and never removed it, so each run of the suite left one there. It now removes it once the test finished. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ts, so none leaves a ledger Its tests kept the server of onAlpha in one variable that afterEach stopped, and the test of the definition tools called onAlpha twice, so its first server ran on unstopped and left its auto-runtime-server- folder, the ledger with its 1.1 MB WAL, under the temporary directory on every run of the suite. onAlpha now stops the server it starts once the test finished. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…s teardown checks and removes The helpers that make a folder remove it on onTestFinished or in a finally, which a worker that dies, a hook that times out or a child that is killed never reaches, so the suites left their folders under the machine's temporary directory. vitest.shared.ts now names a global setup, aFolderOfTheTestRun of @on.auto/operations, that makes auto-runtime-test-run-<project>-<random> in the temporary folder and sets TMPDIR to it before any worker starts, so tmpdir() answers it in every worker and in every process a test starts with the environment it inherits. Its teardown lists what the tests left there, ends any process the setup's runningIn finds still running in an entry, fails the run naming each entry and each process, and removes the folder whatever happened. Two runs at once have two folders. The ending of a process, SIGTERM and SIGKILL after stoppedWithinMs, moves from test-processes.ts to process-endings.ts, which imports nothing of Vitest, since a global setup runs in Vitest's own process. turbo.json counts both files among its global dependencies, as it counts vitest.shared.ts, since the tests of every package run under them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…eft running, and names it A runtime a relay starts with start --background --instance <id> runs in a process group of its own, and runtimesStartedInTheBackgroundEndedWithTheTest ends it in onTestFinished, which a worker that dies or a hook that times out never reaches, so under load such a runtime ran on after the run. The server's vitest.config.ts now names src/testing/test-run/test-run-folder.ts in place of the shared global setup, through sharedConfigSetUpBy of vitest.shared.ts: aFolderOfTheTestRun over runtimesStillRunningInTheBackgroundIn, which reads the runtime.log of each home left in the run's folder for a start with no end, as the hook of a test does. A process is ended, SIGTERM and SIGKILL after stoppedWithinMs, only while ps shows it runs under the instance the log named, and the failure of the run names it with its home. The reading of the log moves to runtimes-in-the-background.ts, which imports nothing of Vitest, and the hook of a test ends what it finds with endedWhileItRuns of @on.auto/operations/testing. @on.auto/operations/test-run-folder is the entry a package's own global setup imports. The check that a process the log says ended, or one that runs as another, is left alone is the teardown's test now, beside the reading the hook and the teardown share, and the relay's test keeps to the relay. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
rami-hatoum
force-pushed
the
test/a-test-run-owns-its-temporary-folder
branch
from
October 22, 2026 07:36
9b3d71e to
9206dc3
Compare
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 this changes
The suites leaked. On a machine that runs them, the temporary directory held 18 GB of folders the tests had made and never removed, thousands under each package's prefix, and the server suite left one ledger folder per run and, under load, a background runtime still running. Every helper removes what it makes on
onTestFinishedor in afinally, which a worker that dies, a hook that times out or a child that is killed never reaches, and nothing ever looked.Now each test run owns a temporary folder of its own.
vitest.shared.tsso every package has it, makes one folder under the machine's temporary directory, named for the run, and setsTMPDIRto it before any worker starts, soos.tmpdir()in every worker and in every process a test spawns answers that folder. The helpers needed no change for this.runtime.logfor a runtime started in the background with no ending, ends it only whilepsshows the instance the log named, SIGTERM then SIGKILL, and names it in the failure. The per-test hook that did this reads the log through the same function.The gate then showed three leaks, each fixed at its root:
turbo.jsonlists the setup's files underglobalDependencies, so a change to them invalidates every package's cached test results, including those of packages that do not depend on operations.Tests
Checklist
feat(reasoning): .... It becomes the squash commit and the changelog entry.pnpm checkpasses locally, with every file at 100% coverage.