Repository navigation
fix: keep the project folder inside a long cache root; leave no test temp files - #105
Conversation
[Medium impact] The PR appears safe to merge; no new blocking issue was found. SummaryKeeps project folders inside long cache roots and adds test cleanup and TMPDIR guards.
Reviews (4) · Last reviewed commit: "docs: keep pending changelog entries und..." · Reviewed by Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Retested 4fbd4df as in #102, each test file alone in a fresh TMPDIR ( |
…temp files opencodeProjectDir cut the whole path to 84 characters, so with a long cache root the project folder (agent-tools, terminals) was created next to the cache directory. Cut only the slug. Below an 83-character root the name is the one the old cut produced, so existing folders keep their location. The suite left about 200 TMPDIR entries per run with a long TMPDIR: - background-spawn tests kept their logs and a detached child (reapBackgroundSpawn) - a stop saved the cancelled Run after the test removed its cache dir (settleHostInterruptsForTests, in write-drain and the Node drain script) - terminal supervisors wrote job files after cleanup (stopProcessesUsing, in terminal-runner and runtime-files-pump) bunfig.toml preloads test/preload.ts: every bun test run gets a private TMPDIR, fails when anything is left in it, and removes it. Node test scripts import test/node-tmpdir.mjs for the same guard. AGENTS.md now says never to leave TMPDIR remnants. Fixes #102
…ache roots
Review: with an 83-character projects root the old cut already ended at
`projects/` and named the folder `-<hash>`; cutting only the slug renamed it
to `<hash>`. Keep the old name whenever the cut falls after `projects/`, and
name the folder by the hash alone only for longer roots.
CI (Linux): three tests left the process-wide host cache root that
createCursor({ cacheDir }) sets pointing at their removed temp dirs, so later
files wrote project folders, models and client-version caches there, and on
some file orders tests expecting the default root failed. Restore the root
after each test. The lifecycle test also closes its held Run and waits for
its save before removing the dir; settleRunSavesForTests now waits for every
in-progress Run save, not only host-interrupt cancels.
The TMPDIR guard now lists the leftover files.
4fbd4df to
bd08dfc
Compare
Fixes #102.
Problem
A clean
bun testleaves entries in TMPDIR, and they pile up with every run. Onmain, with a TMPDIR of about 90 characters per test file, 18 files left 197 entries. One cause also affects real use.Causes and fixes
Project folder outside a long cache root (real use too).
opencodeProjectDircut the whole path to 84 characters plus a hash. When the cache root itself is long, the cut lands inside the root, soagent-tools/andterminals/are created next to the cache dir.projects/(a projects root shorter than 84 characters), the name is the old one verbatim, so existing project folders don't move. A longer root, where the old cut fell inside the root, now names the folder by its hash insideprojects/.Background spawns. Three tests ran the real
buildBackgroundShellCommandand kept itscursor-opencode-bg.*log. One also left a detachedsleep 10running.reapBackgroundSpawn(intest/background-spawn.ts) reads the printed marker, kills the child and removes the log.A stop's save after cleanup. In
write-drain's "cancels an unregistered replacement upload", the cancelled Run saves its snapshot from the host-interrupt handler. That happens about 30 ms after the test'sfinallyhas removed the cache dir. The Node drain scenario does the same.settleRunSavesForTests, waits for host-interrupt cancels and every in-progress Run save.A cache root left set for later tests (Linux file order).
createCursor({ cacheDir })sets the process-wide host cache root. Three tests never restored it, so later files wrote project folders, model and client-version caches into their removed temp dirs. With some file orders, tests that expect the default root failed too. Those three tests now restore the root after each test.Terminal supervisors after
afterEach. A launcher that hadn't writtenreadyyet was skipped by cleanup, then started and recreated its job files.runtime-files-pumphas the same race with a managed terminal.stopProcessesUsing(dir)(intest/process-cleanup.ts) waits for every process that names the test root, kills those that don't finish within 3 s, and only then lets the root go.terminal-runnercalls it only when a job directory exists.Guard so this stays fixed:
bunfig.tomlpreloadstest/preload.ts. It gives everybun testrun a private TMPDIR, fails the run if anything is left in it, and removes it either way.test/node-tmpdir.mjsdoes the same for the Node HTTP/2 scripts.AGENTS.md now has a working-convention rule: never leave TMPDIR remnants, whether from tests, scripts or scratch work.
Validation of rebased head bd08dfc
Rebased onto main after #104 merged as 83506c2. All four #105 commits are retained. Only the overlapping release-publication lesson needed a conflict resolution; both changelog entries remain under unreleased 0.8.3.
bun test --coverage: 2,377 pass, 0 fail across 108 files; the TMPDIR guard passes.bun run test:node-http2passes, including its temporary-file guards.bun run check:pricingcovers all 54 priced model fixtures.Original validation (before the rebase)
bun testbun test --coverageas in CI/tmpbun run test:node-http2cursor-node-upload-cancel-*leftbun run typecheck,bun run buildandtest/architecture.test.tspass.terminal-runner.test.tsruns about 5 s slower (one process listing per test that started a job). The whole suite is about 4 s slower.paths.test.ts: a long cache root keeps the folder insideprojects/, the name an existing folder already has stays the same, and 83- and 84-character projects roots get the expected names.The changelog entry is under 0.8.3, which is not tagged yet, and covers only the project-folder fix that users can notice.