Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `version-sync.sh` no longer flags frozen fixture constants: a source-constant line
carrying `# version-sync: ignore` is skipped (applied to the `FIXTURE_VERSION` in
`tests/test_docs_staleness_prose.py`); unmarked stale constants are still flagged.
- Eight bash test suites no longer leak temp directories. `make_tmpdir` ran in a
`$(...)` subshell, so its cleanup registration never reached the `EXIT` trap; each run
now creates one unique root in the parent shell and removes it on exit. Guarded by
`tests/test_tmpdir_cleanup.sh`, which runs each suite with an isolated `TMPDIR`.

## [4.8.2] - 2026-10-31

Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `version-sync.sh` no longer flags frozen fixture constants: a source-constant line
carrying `# version-sync: ignore` is skipped (applied to the `FIXTURE_VERSION` in
`tests/test_docs_staleness_prose.py`); unmarked stale constants are still flagged.
- Eight bash test suites no longer leak temp directories. `make_tmpdir` ran in a
`$(...)` subshell, so its cleanup registration never reached the `EXIT` trap; each run
now creates one unique root in the parent shell and removes it on exit. Guarded by
`tests/test_tmpdir_cleanup.sh`, which runs each suite with an isolated `TMPDIR`.

## [4.8.2] - 2026-10-31

Expand Down
7 changes: 6 additions & 1 deletion tests/test_branch_guard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ fi
# ============================================================================

# Create a temp directory and register it for cleanup
# One unique root per run, created in the parent shell: make_tmpdir runs in a
# $(...) subshell, so appending to CLEANUP_DIRS there never reaches the EXIT trap.
RUN_TMP=$(mktemp -d "${TMPDIR:-/tmp}/branch-guard-test-run.XXXXXX")
CLEANUP_DIRS+=("$RUN_TMP")

make_tmpdir() {
local dir
dir=$(mktemp -d "${TMPDIR:-/tmp}/branch-guard-test.XXXXXX")
dir=$(mktemp -d "${RUN_TMP}/d.XXXXXX")
CLEANUP_DIRS+=("$dir")
echo "$dir"
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_branch_guard_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,14 @@ fi
# Helpers (same pattern as test_branch_guard.sh)
# ============================================================================

# One unique root per run, created in the parent shell: make_tmpdir runs in a
# $(...) subshell, so appending to CLEANUP_DIRS there never reaches the EXIT trap.
RUN_TMP=$(mktemp -d "${TMPDIR:-/tmp}/branch-guard-e2e-run.XXXXXX")
CLEANUP_DIRS+=("$RUN_TMP")

make_tmpdir() {
local dir
dir=$(mktemp -d "${TMPDIR:-/tmp}/branch-guard-e2e.XXXXXX")
dir=$(mktemp -d "${RUN_TMP}/d.XXXXXX")
CLEANUP_DIRS+=("$dir")
echo "$dir"
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_git_dryrun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ cleanup() {
}
trap cleanup EXIT

# One unique root per run, created in the parent shell: make_tmpdir runs in a
# $(...) subshell, so appending to CLEANUP_DIRS there never reaches the EXIT trap.
RUN_TMP=$(mktemp -d "${TMPDIR:-/tmp}/git-dryrun-test-run.XXXXXX")
CLEANUP_DIRS+=("$RUN_TMP")

make_tmpdir() {
local dir
dir=$(mktemp -d "${TMPDIR:-/tmp}/git-dryrun-test.XXXXXX")
dir=$(mktemp -d "${RUN_TMP}/d.XXXXXX")
CLEANUP_DIRS+=("$dir")
echo "$dir"
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_git_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ cleanup() {
}
trap cleanup EXIT

# One unique root per run, created in the parent shell: make_tmpdir runs in a
# $(...) subshell, so appending to CLEANUP_DIRS there never reaches the EXIT trap.
RUN_TMP=$(mktemp -d "${TMPDIR:-/tmp}/git-utils-test-run.XXXXXX")
CLEANUP_DIRS+=("$RUN_TMP")

make_tmpdir() {
local dir
dir=$(mktemp -d "${TMPDIR:-/tmp}/git-utils-test.XXXXXX")
dir=$(mktemp -d "${RUN_TMP}/d.XXXXXX")
CLEANUP_DIRS+=("$dir")
echo "$dir"
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_insights_improvements_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,14 @@ fi
# Helpers
# ============================================================================

# One unique root per run, created in the parent shell: make_tmpdir runs in a
# $(...) subshell, so appending to CLEANUP_DIRS there never reaches the EXIT trap.
RUN_TMP=$(mktemp -d "${TMPDIR:-/tmp}/insights-e2e-run.XXXXXX")
CLEANUP_DIRS+=("$RUN_TMP")

make_tmpdir() {
local dir
dir=$(mktemp -d "${TMPDIR:-/tmp}/insights-e2e.XXXXXX")
dir=$(mktemp -d "${RUN_TMP}/d.XXXXXX")
CLEANUP_DIRS+=("$dir")
echo "$dir"
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_marketplace_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ fi
# Helpers
# ============================================================================

# One unique root per run, created in the parent shell: make_tmpdir runs in a
# $(...) subshell, so appending to CLEANUP_DIRS there never reaches the EXIT trap.
RUN_TMP=$(mktemp -d "${TMPDIR:-/tmp}/marketplace-e2e-run.XXXXXX")
CLEANUP_DIRS+=("$RUN_TMP")

make_tmpdir() {
local dir
dir=$(mktemp -d "${TMPDIR:-/tmp}/marketplace-e2e.XXXXXX")
dir=$(mktemp -d "${RUN_TMP}/d.XXXXXX")
CLEANUP_DIRS+=("$dir")
echo "$dir"
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_no_switch_guard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ fi
# ============================================================================

# Create a temp directory and register it for cleanup
# One unique root per run, created in the parent shell: make_tmpdir runs in a
# $(...) subshell, so appending to CLEANUP_DIRS there never reaches the EXIT trap.
RUN_TMP=$(mktemp -d "${TMPDIR:-/tmp}/no-switch-guard-test-run.XXXXXX")
CLEANUP_DIRS+=("$RUN_TMP")

make_tmpdir() {
local dir
dir=$(mktemp -d "${TMPDIR:-/tmp}/no-switch-guard-test.XXXXXX")
dir=$(mktemp -d "${RUN_TMP}/d.XXXXXX")
CLEANUP_DIRS+=("$dir")
echo "$dir"
}
Expand Down
7 changes: 6 additions & 1 deletion tests/test_release_skill_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ fi
# Helpers
# ============================================================================

# One unique root per run, created in the parent shell: make_tmpdir runs in a
# $(...) subshell, so appending to CLEANUP_DIRS there never reaches the EXIT trap.
RUN_TMP=$(mktemp -d "${TMPDIR:-/tmp}/release-skill-e2e-run.XXXXXX")
CLEANUP_DIRS+=("$RUN_TMP")

make_tmpdir() {
local dir
dir=$(mktemp -d "${TMPDIR:-/tmp}/release-skill-e2e.XXXXXX")
dir=$(mktemp -d "${RUN_TMP}/d.XXXXXX")
CLEANUP_DIRS+=("$dir")
echo "$dir"
}
Expand Down
48 changes: 48 additions & 0 deletions tests/test_tmpdir_cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# Guards against temp-dir leaks in the bash test suites.
#
# Each suite's make_tmpdir is called as dir=$(make_tmpdir), which runs in a
# subshell, so its CLEANUP_DIRS+= never reaches the parent and the EXIT trap
# removes nothing. Each suite runs here with its own empty TMPDIR; after it
# exits the TMPDIR must be empty again. (The suites' pass/fail results are not
# judged here, only what they leave behind.)
#
# Usage: ./tests/test_tmpdir_cleanup.sh

set -uo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

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
)

PASS=0
FAIL=0
BASE="$(mktemp -d)"
trap 'rm -rf "$BASE"' EXIT

for suite in "${SUITES[@]}"; do
iso="$BASE/$suite"
mkdir -p "$iso"
TMPDIR="$iso" bash "$SCRIPT_DIR/$suite.sh" >/dev/null 2>&1
left=$(find "$iso" -mindepth 1 -maxdepth 1 | wc -l | tr -d ' ')
if [[ "$left" -eq 0 ]]; then
echo " ✓ $suite leaves no temp dirs"
PASS=$((PASS + 1))
else
echo " ✗ $suite leaked $left temp dir(s)"
FAIL=$((FAIL + 1))
fi
done

echo ""
echo "Results: $PASS passed, $FAIL failed"
[[ "$FAIL" -eq 0 ]]
Loading