Repository navigation
fix(test): remove profile and console browser scratch dirs after runs - #2967
Merged
Merged
Conversation
Profile renderer tests left one oce-profile-* directory per render under TMPDIR (446 per run of the two files), and console browser tests left one openclaw-console-agents-browser-* directory per page, although the testing guide says screenshots are kept only with OCC_TEST_CONSOLE_ARTIFACT_DIR. Add fileTemporaryDirectory, which removes its directories after the test file's last test, use it for the renderer's default output directory, and remove the console artifact directory when its test ends. A conformance test runs a fixture file under an empty TMPDIR and checks it stays empty, including after a failing test.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review blockedAutomated review did not run, so no review verdict was produced. Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here. Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update. Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it. |
Say when the file-level hook runs under --test-isolation=none, and drop the public-read test's own removal of its render directory, which the file-level cleanup now covers.
This was referenced Oct 20, 2026
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.
Problem
Local test runs share one TMPDIR, and two harnesses never removed their scratch directories:
render()inprofile-renderer.test.mjsandprofile-public-github-read.test.mjscreates anoce-profile-<profile>-*directory for each render and never removes it. One run of the two files leaves 446 directories (230 codex, 215 openclaw, 1 default).newPage()intests/browser/console-agents-browser-helpers.mjscreates anopenclaw-console-agents-browser-*directory for each page and never removes it, even thoughdocs/testing/local.mdsays screenshots are kept only whenOCC_TEST_CONSOLE_ARTIFACT_DIRis set. One run ofconsole-agent-channelsandconsole-agent-plugin-approversleaves 25.On a shared dev host these had built up to about 283k top-level entries (117k console artifact dirs, mostly empty, and 165k profile dirs).
Change
tests/helpers/temporary-directory.mjswithfileTemporaryDirectory(prefix). It creates a directory under TMPDIR and removes it after the file's last test, whether tests pass or fail, using a file-levelafterhook added on import (the same pattern astests/helpers/dev-up.mjs). The renderer outputs stay readable across tests in the file.render()'s default output directory.t.afterwhen its test ends, unlessOCC_TEST_CONSOLE_ARTIFACT_DIRis set (that directory is kept, as documented).tests/conformance/temporary-directory.test.mjsruns a fixture test file under an empty TMPDIR. The fixture creates directories at module scope, in a passing test and in a failing test. The parent test checks that they existed during the run and that TMPDIR is empty afterwards. It is mapped tochecks-baseline-1.Verification
rmSyncfails it with a non-empty TMPDIR.node scripts/ci/run-tests.mjs audit: no issues. prettier and eslint are clean on the touched files.Risks
Test-only. Anyone who relied on finding console screenshots in the default temp directory after a local run must now set
OCC_TEST_CONSOLE_ARTIFACT_DIR, which is what the testing guide already says. Killed runs still leave their directories, because no teardown runs.