Skip to content

Commit b9846fe

Browse files
authored
test(release): clean up the guard test's scratch dir without an EXIT trap (#3673)
## What this PR does `make unit-tests` fails on a clean `main`: `hack/bats-no-exit-trap.bats` reports `release-freeze-contract.bats` as holding one EXIT trap with no declaration. Neither change that produced this was wrong on its own. The per-file trap guard replaced a frozen global count with declarations carried by each file, and the backport guard test arrived with an EXIT trap from a branch that predated the guard. Each was green against its own base; together they are red. The fix follows the convention the guard exists to promote rather than declaring fresh debt: the scratch directory is removed on the last line of the test body. That also preserves the behaviour the rule is for, since a failing test never reaches the cleanup and leaves its directory behind for inspection. ## Testing `hack/release-freeze-contract.bats` and `hack/bats-no-exit-trap.bats` both pass on this branch. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Improved cleanup of temporary test files after release-freeze validation. - Preserved existing validation of release-freeze guard behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 1b17888 + a042c2d commit b9846fe

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎hack/release-freeze-contract.bats‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,6 @@ step_line() {
331331
@test "the guard's merged decision is correct on empty, closed-unmerged and closed-merged lists" {
332332
command -v node >/dev/null || { echo "node unavailable; skipping"; return 0; }
333333
tmp="$(mktemp -d)"
334-
# shellcheck disable=SC2064
335-
trap "rm -rf '$tmp'" EXIT
336334

337335
cat > "$tmp/guard.js" <<'JS'
338336
function alreadyMerged(prs) {
@@ -370,4 +368,6 @@ closed-merged=true"
370368
[ -n "$block" ]
371369
printf '%s\n' "$block" | script_lines | grep -qF 'prs.some(p => p.merged_at !== null)' || {
372370
echo "backport.yaml's guard no longer uses prs.some(p => p.merged_at !== null)." >&2; exit 1; }
371+
372+
rm -rf "$tmp"
373373
}

0 commit comments

Comments
 (0)