āœ… test(pariksha): shell-sources tests leave no temp folder behind

Merged
AT
9d ago
+29-7

Slice: #369

packages/pariksha/src/shell-sources.test.ts now leaves no shell-sources-* folder in its temp directory, so scripts/fresh-tmpdir.mjs no longer reports one. This changes one test file and nothing that ships, so there is no version bump.

What changed

  • Fixture git runs with -c maintenance.auto=false -c gc.auto=0. This was the one pariksha git fixture without those flags. With git ≄ 2.47 (2.54 here), each fixture git commit starts git maintenance run --auto --quiet --detach, which keeps running after the commit returns (GIT_TRACE=2 shows it). That child can write into the fixture's .git/objects while afterEach removes it. With the flags set, the trace shows no maintenance child. The selectors under test only run read-only git (ls-files, show, cat-file --batch, diff).
  • Cleanup no longer depends on repo. beforeEach records each mkdtempSync folder before anything else can throw. afterEach removes the recorded folders with maxRetries: 5. A folder it cannot remove stays recorded, and a final after() tries again. The old afterEach removed dirname(repo), which is '.' while repo is still unset.

Evidence

The leak was not reproduced locally. I also could not find the CI log that reported /tmp/vt-zSZ6fG/shell-sources-HmmTlG: no CI job on #360's branch that I could reach has it. So which failure mode happened there (a removal that threw ENOTEMPTY, or a folder that survived a clean removal) is not pinned down, and the fix covers both.

  • Scratch loop (init, commit, immediate rmSync), 150 iterations on macOS: 0 leaks, 0 throws.
  • The original test file under fresh-tmpdir, 6 copies at once for 5 rounds: 0 of 30 leaked. The fixed file under the same load: 0 of 30.
  • Injected failures in the fixed file, each run under fresh-tmpdir: a throwing test body and a beforeEach that throws right after mkdtemp both left nothing.
  • Control: with cleanup skipped, fresh-tmpdir reported all 36 folders and failed the run.
  • Untested: the path where afterEach throws and after() removes the folder on retry.

A leak fails every time already. pariksha's test script runs through fresh-tmpdir, which fails a passing run that leaves anything behind. scripts/fresh-tmpdir.test.mjs already covers this: "a passing run that left a path fails with 1 and names it" (line 77) and the spawned-program test (line 241). Per #369, no new test was added for it.

pnpm --filter @veda-hq/pariksha check is green locally: 4006 tests pass and fresh-tmpdir reports nothing.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes packages/pariksha's shell-sources.test.ts so a passing run no longer leaves a shell-sources-* temp folder behind, which was making fresh-tmpdir fail (part of #369).

  • Fixture git runs now pass -c maintenance.auto=false -c gc.auto=0; otherwise each git commit starts a detached git maintenance run --auto that can write into the fixture while afterEach removes it.
  • Cleanup no longer depends on repo: beforeEach records each mkdtemp folder before anything can throw, and afterEach plus a final after removes the recorded folders with retries.