Skip to content

test: remove the temp dirs the remaining suites leak (#1777) - #1937

Open
danusha2345 wants to merge 2 commits into
colbymchenry:mainfrom
danusha2345:fix/test-temp-dir-leaks-rest
Open

danusha2345 wants to merge 2 commits into
colbymchenry:mainfrom
danusha2345:fix/test-temp-dir-leaks-rest

Conversation

@danusha2345

@danusha2345 danusha2345 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Update (16 Oct): #2622 on main now removes the temp dirs of function-ref, ts-field-classification, pr19-improvements, liveness-watchdog and npm-sdk, and adds a home sandbox. This PR is trimmed to the two suites it does not cover: index-orphan-watchdog (its tmpDir was cleared before afterEach could remove it) and npm-shim (the staged shim's temp dir). Two files, +15/-5.


Refs #1777. This complements #1786 (resolution.test.ts) and #1787 (mcp-writer-lock.test.ts daemon) by bompus, and covers the suites those two don't touch.

Measured

I ran the full suite on Linux with a private TMPDIR, so parallel runs can't skew the count, and listed what was left behind:

suite dirs leaked per run
resolution.test.ts 187 (fixed by #1786)
npm-shim.test.ts 22
function-ref.test.ts 20
extraction.test.ts, ts-field-classification.test.ts, liveness-watchdog.test.ts, npm-sdk.test.ts 3 each
extraction-old-git.test.ts, pr19-improvements.test.ts, index-orphan-watchdog.test.ts 1 each

With #1786 and #1787 applied, 57 dirs still leak. With this PR on top: 0 dirs and 0 orphaned daemons.

Changes (test code only)

  • function-ref.test.ts, ts-field-classification.test.ts: each test's finally reset tmpDir = undefined. That runs before the afterEach that removes the directory, so the removal never saw it. Dropped the reset; afterEach already removes the directory and resets the variable.
  • extraction.test.ts (the init silently reports success on an unsupported-language project (0 files, index_state: complete) #1502 group), extraction-old-git.test.ts, pr19-improvements.test.ts, index-orphan-watchdog.test.ts, liveness-watchdog.test.ts: added cleanup where none existed.
  • npm-shim.test.ts, npm-sdk.test.ts: mkTmp now records each directory it creates, and an afterAll removes them.

No product code changed.

The full suite passes: 4718 passed, and the same with #1786/#1787 applied, which this PR doesn't conflict with. Windows wasn't checked.

🤖 Generated with Claude Code

@danusha2345
danusha2345 force-pushed the fix/test-temp-dir-leaks-rest branch from dc210b4 to 49c9054 Compare September 27, 2026 17:06
danusha2345 pushed a commit to danusha2345/codegraph that referenced this pull request Sep 27, 2026
danusha2345 pushed a commit to danusha2345/codegraph that referenced this pull request Sep 27, 2026
@danusha2345
danusha2345 force-pushed the fix/test-temp-dir-leaks-rest branch 3 times, most recently from 7acfd6f to 8b70f50 Compare October 21, 2026 17:59
danusha2345 and others added 2 commits October 22, 2026 10:45
extraction.test.ts (colbymchenry#1502 scan-skip describe), extraction-old-git.test.ts,
pr19-improvements.test.ts (schema-version db), index-orphan-watchdog.test.ts
and liveness-watchdog.test.ts each mkdtemp'd a directory and never removed it:
9 directories per suite run between them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mkTmp hands directories to helpers shared by many tests, so no single test
owned their cleanup and none happened: 22 cg-shim-* and 3 cg-sdk-* directories
leaked per run. mkTmp now records each one and an afterAll removes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@danusha2345
danusha2345 force-pushed the fix/test-temp-dir-leaks-rest branch from 8b70f50 to 589f61d Compare October 22, 2026 10:50
malarinv pushed a commit to malarinv/codegraph that referenced this pull request Nov 7, 2026
Two POSIX-only test files still leave temp dirs behind on every macOS
and Linux run. npm-shim.test.ts's mkTmp hands its dirs to helpers that
many tests share, so no single test owned them and none was removed.
index-orphan-watchdog.test.ts makes a cg-index-orphan-* dir for the
child's stderr log and never removes it. PR colbymchenry#2622 fixed the leaks that
show on Windows; these two files skip there, so it could not see them.

mkTmp now records each dir, and a file-level afterAll removes them once
every suite in the file is done, after the HTTPS fixture server has
closed. The orphan test keeps its dir in a variable that afterEach
removes after it has killed the wrapper and the child.

Validation: not run on macOS or Linux, where these tests run; it needs
a POSIX run before merge. On Windows both files skip their POSIX tests
(npm-shim: 1 passed, the windowsHide check, and 10 skipped;
index-orphan-watchdog: 1 skipped), and the new afterAll runs with
nothing to remove. A type-check of both files adds no errors
(index-orphan-watchdog has the same 2 pre-existing ones as on main).
Test-only, so no CHANGELOG entry.

Original PR colbymchenry#1937 by @danusha2345.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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