Skip to content

fix(runner): remove the run-output scratch dir on exit#811

Merged
Chemaclass merged 1 commit into
mainfrom
fix/run-output-dir-leak
Jul 16, 2026
Merged

fix(runner): remove the run-output scratch dir on exit#811
Chemaclass merged 1 commit into
mainfrom
fix/run-output-dir-leak

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Every invocation created $TMPDIR/bashunit/run/<os>/<random> (#801) but nothing removed it — one leaked directory per run (~9.9k had accumulated locally; the acceptance suite alone leaks ~258 per pass).

💡 Changes

  • Guarded cleanup in env.sh (path-checked like parallel::cleanup), armed via an EXIT trap for early-exit paths (--version, --help, subcommands).
  • The test-run path replaces that trap, so cmd_test calls the cleanup explicitly after rerun::persist; Ctrl-C and stop-on-failure handlers do the same.
  • Sourcing errors are now captured in the run dir too — files are sourced sequentially in the parent, so a fixed per-file-truncated path is safe and saves a mktemp + rm fork per test file.
  • Regression test runs a nested bashunit under a private TMPDIR and asserts nothing is left. SIGKILLed runs still can't clean up (no trap runs); a full suite now leaves ~6 dirs instead of ~258.

Every invocation created $TMPDIR/bashunit/run/<os>/<random> (#801) but nothing
removed it, leaking one directory per run — ~9.9k dirs had accumulated locally.

- env.sh gains a guarded cleanup (mirrors parallel::cleanup's path check) and
  arms it via an EXIT trap for early-exit paths (--version, --help, doc, ...).
- The test-run path replaces that trap in main.sh, so cmd_test calls the
  cleanup explicitly after rerun::persist (which reads from the run dir), and
  the Ctrl-C / stop-on-failure handlers do the same before their exits.
- Sourcing errors are captured in the run dir as well: files are sourced
  sequentially in the parent (workers fork after), so a fixed truncated-per-file
  path is safe and saves a mktemp and an rm fork per test file.

Runs killed with SIGKILL still cannot clean up (no trap runs); a full local
suite now leaves ~6 dirs instead of ~258.
@Chemaclass Chemaclass added the bug Something isn't working label Jul 16, 2026
@Chemaclass Chemaclass self-assigned this Jul 16, 2026
@Chemaclass Chemaclass merged commit c86c220 into main Jul 16, 2026
37 checks passed
@Chemaclass Chemaclass deleted the fix/run-output-dir-leak branch July 16, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant