Skip to content

test: prefer shared temp dir helpers in auto-reply and install-fallback tests#96048

Closed
xialonglee wants to merge 1 commit into
openclaw:mainfrom
xialonglee:main
Closed

test: prefer shared temp dir helpers in auto-reply and install-fallback tests#96048
xialonglee wants to merge 1 commit into
openclaw:mainfrom
xialonglee:main

Conversation

@xialonglee

Copy link
Copy Markdown
Contributor

What Problem This Solves

~100+ test files still use raw fs.mkdtemp/fs.mkdtempSync instead of the shared temp directory helpers in src/test-helpers/temp-dir.ts. This causes:

  1. Disk leaks — temp dirs created but never cleaned up
  2. Parallel test conflicts — concurrent tests may collide on /tmp paths
  3. Inconsistent patterns — CI (scripts/report-test-temp-creations.mjs) already warns against new raw mkdtemp calls

Why This Change Was Made

The project has shared helpers (createSuiteTempRootTracker, withTempDir) since commit 88b87d8 that handle automatic cleanup with retries. This PR migrates the first batch of high-risk files that have zero cleanup.

User Impact

  • No user-facing impact. Test-only changes.
  • CI temp dir pressure reduced for repeated test runs.

Evidence

  • 95 tests pass across 4 modified files
  • Each file now uses createSuiteTempRootTracker() with proper beforeAll/afterAll cleanup

Files Changed

File Risk Fix
src/skills/lifecycle/install-fallback.test.ts P0 — variable overwrite, only last dir cleaned createSuiteTempRootTracker()
src/auto-reply/reply/session-hooks-context.test.ts P0 — helper leaked temp dirs createSuiteTempRootTracker()
src/auto-reply/reply/abort.test.ts P0 — createAbortConfig leaked root dir createSuiteTempRootTracker()
src/auto-reply/inbound.test.ts P0 — 2 test cases created dirs without cleanup createSuiteTempRootTracker()

…ck tests

Replace raw fs.mkdtemp/mkdtempSync calls with createSuiteTempRootTracker()
for automatic cleanup and consistent temp directory management.

- session-hooks-context.test.ts: mkdtemp in helper leaked temp dirs
- abort.test.ts: createAbortConfig mkdtemp returned root without cleanup
- inbound.test.ts: two test cases created temp dirs without cleanup
- install-fallback.test.ts: workspaceDir variable could be overwritten

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant