fix(tests): stop fixture helpers leaking temp dirs into /tmp
Why: new_repo/make_fixture/make_repo created a mktemp dir and appended it to the cleanup array, but every caller runs them as R="$(helper)". The append happens in that command-substitution subshell and is lost, so the EXIT trap removed nothing. Each run leaked one dir per call: 31, 54, 22 and 9 for the four suites, about 1,700 dirs on one day. Implementation Notes: - Each suite creates one RUN_TMP root up front with a single `trap 'rm -rf "$RUN_TMP"' EXIT`; every fixture is `mktemp -d` under it, so cleanup no longer depends on where the helper runs. - The CLEANUP_DIRS / FIXTURES arrays are gone from these four suites. - test-check-scope-walkup-sync.sh and test-check-apm-agents-valid.sh already register fixtures in the caller and are unchanged. Assisted-by: Claude Code
This commit is contained in:
1 parent
8ffff54fbc
commit
da88cd8d32
4 files changed
+29
-30
No files matched your search
@@ -10,14 +10,12 @@ FAIL=0
|
||||
pass() { echo " PASS: $1"; PASS=$((PASS + 1)); }
|
||||
fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }
|
||||
|
||||
FIXTURES=()
|
||||
cleanup() { [[ ${#FIXTURES[@]} -eq 0 ]] || rm -rf "${FIXTURES[@]}"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
# Per-run scratch for captured output, for the reason check-scope-walkup-sync's
|
||||
# test gives: tests/run-tests.sh fans test scripts out concurrently.
|
||||
# Per-run scratch for output and fixtures, for the reason check-scope-walkup-sync's
|
||||
# test gives: tests/run-tests.sh fans test scripts out concurrently. Fixtures live
|
||||
# under it because make_repo runs in a $(...) subshell, where an array append never
|
||||
# reaches the parent's trap.
|
||||
RUN_TMP="$(mktemp -d)"
|
||||
FIXTURES+=("$RUN_TMP")
|
||||
trap 'rm -rf "$RUN_TMP"' EXIT
|
||||
|
||||
# A minimal REPO_ROOT: a .git entry (the validator's find_repo_root stops at
|
||||
# it), a copy of the real validator at its real relative path, and one plugin
|
||||
@@ -25,8 +23,7 @@ FIXTURES+=("$RUN_TMP")
|
||||
# exercise the actual FAIL/INFO/exit contract rather than a stub of it.
|
||||
make_repo() {
|
||||
local dir
|
||||
dir="$(mktemp -d)"
|
||||
FIXTURES+=("$dir")
|
||||
dir="$(mktemp -d "$RUN_TMP/fx.XXXXXX")"
|
||||
mkdir -p "$dir/.git" "$dir/$VALIDATOR_DIR" "$dir/plugins/p/docs/research/docs/t"
|
||||
cp -R "$REPO_ROOT/$VALIDATOR_DIR/." "$dir/$VALIDATOR_DIR/"
|
||||
cat > "$dir/plugins/p/docs/research/docs/t/sources.md" <<'EOF'
|
||||
|
||||
Reference in new issue
Block a user