Skip to content

fix(test): remove profile and console browser scratch dirs after runs - #2967

Merged
freeqaz merged 2 commits into
mainfrom
state-t-cleanup
Oct 20, 2026
Merged

freeqaz merged 2 commits into
mainfrom
state-t-cleanup

Conversation

@freeqaz

@freeqaz freeqaz commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Problem

Local test runs share one TMPDIR, and two harnesses never removed their scratch directories:

  • render() in profile-renderer.test.mjs and profile-public-github-read.test.mjs creates an oce-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() in tests/browser/console-agents-browser-helpers.mjs creates an openclaw-console-agents-browser-* directory for each page and never removes it, even though docs/testing/local.md says screenshots are kept only when OCC_TEST_CONSOLE_ARTIFACT_DIR is set. One run of console-agent-channels and console-agent-plugin-approvers leaves 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

  • Add tests/helpers/temporary-directory.mjs with fileTemporaryDirectory(prefix). It creates a directory under TMPDIR and removes it after the file's last test, whether tests pass or fail, using a file-level after hook added on import (the same pattern as tests/helpers/dev-up.mjs). The renderer outputs stay readable across tests in the file.
  • Both profile test files use it for render()'s default output directory.
  • The console artifact directory is removed by t.after when its test ends, unless OCC_TEST_CONSOLE_ARTIFACT_DIR is set (that directory is kept, as documented).
  • New tests/conformance/temporary-directory.test.mjs runs 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 to checks-baseline-1.

Verification

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.

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.
@freeqaz
freeqaz requested a review from a team as a code owner October 19, 2026 21:25
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review blocked

Automated 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.

View the workflow run.

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.
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 19, 2026
@freeqaz
freeqaz merged commit 556aaf4 into main Oct 20, 2026
60 checks passed
@freeqaz
freeqaz deleted the state-t-cleanup branch October 20, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant