Skip to content

fix: stop 8 bash test suites leaking temp directories - #381

Merged
Data-Wise merged 3 commits into
devfrom
feature/test-tmpdir-cleanup
Nov 1, 2026
Merged

Data-Wise merged 3 commits into
devfrom
feature/test-tmpdir-cleanup

Conversation

@Data-Wise

Copy link
Copy Markdown
Owner

Summary

Eight bash test suites no longer leak temp directories. Each defined make_tmpdir and called it as dir=$(make_tmpdir); that runs in a subshell, so its CLEANUP_DIRS+= never reached the parent shell and the EXIT trap removed nothing. Each suite now creates one unique run root in the parent shell (registered for the existing trap) and make_tmpdir makes its directories inside it. A unique root avoids a prefix glob that could delete another run's directories.

Suites: test_branch_guard, test_branch_guard_e2e, test_git_dryrun, test_git_utils, test_insights_improvements_e2e, test_marketplace_e2e, test_no_switch_guard, test_release_skill_e2e. New guard: tests/test_tmpdir_cleanup.sh runs each suite with an isolated TMPDIR and asserts it is empty afterward.

Evidence

Red first (all 8 suites leaked, 114 dirs in the isolated TMPDIR):

✗ test_branch_guard leaked 64 temp dir(s)
✗ test_branch_guard_e2e leaked 10 temp dir(s)
✗ test_git_dryrun leaked 4 temp dir(s)
✗ test_git_utils leaked 6 temp dir(s)
✗ test_insights_improvements_e2e leaked 1 temp dir(s)
✗ test_marketplace_e2e leaked 7 temp dir(s)
✗ test_no_switch_guard leaked 14 temp dir(s)
✗ test_release_skill_e2e leaked 8 temp dir(s)
Results: 0 passed, 8 failed

After the fix (also re-run after merging origin/dev v4.8.2): Results: 8 passed, 0 failed.

No behavior change in the suites: exit codes match the baseline (test_branch_guard, test_branch_guard_e2e, test_git_dryrun, test_git_utils, test_no_switch_guard exit 0; test_insights_improvements_e2e, test_marketplace_e2e, test_release_skill_e2e exit 1 as on dev, tracked in #377). Nothing leaked into the real $TMPDIR. markdownlint on both changelogs: 0 issues.

Notes

  • Not run: full pytest (only test shell scripts and changelogs changed).
  • Merge commit in this branch merges origin/dev to clear CHANGELOG conflicts; squash-merge drops it.

🤖 Generated with Claude Code

Data-Wise and others added 3 commits October 31, 2026 18:00
make_tmpdir ran inside a command substitution, so its CLEANUP_DIRS registration
never reached the EXIT trap. Each suite now creates one unique run root in the
parent shell and the existing trap removes it. Adds tests/test_tmpdir_cleanup.sh
(red first: 8 of 8 suites leaked 114 dirs; green after the fix).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Data-Wise
Data-Wise merged commit b83b0ac into dev Nov 1, 2026
6 checks passed
@Data-Wise
Data-Wise deleted the feature/test-tmpdir-cleanup branch November 1, 2026 16:19
Data-Wise added a commit that referenced this pull request Nov 1, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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