From 05630fc8b34c4121593f8b077f85531523b558fb Mon Sep 17 00:00:00 2001 From: Alex Barclay Date: Sun, 9 Aug 2026 20:38:43 -0600 Subject: [PATCH] fix(tests): resolve SC2015 in mktemp guards Four identical guards validated mktemp output with A && B || C before installing a 'rm -rf' trap. ShellCheck flagged SC2015 on each. Rewritten as explicit if-statements: same semantics, unambiguous intent. No test assertion is touched; the suite is 202 passing before and after and oracle.lock.json's tests[] array is byte-identical. Three of the four files are hashed by the freeze gate, so R7 will fail until a human reviews this diff and re-locks with --accept. That is deliberate. --- tests/mutate.sh | 2 +- tests/oracle-gate.sh | 2 +- tests/simple-test.sh | 2 +- tests/spec-map.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/mutate.sh b/tests/mutate.sh index 8891d7d..e831751 100644 --- a/tests/mutate.sh +++ b/tests/mutate.sh @@ -11,7 +11,7 @@ PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" MUTANT="${1:-none}" WORK=$(mktemp -d) || { echo "FATAL: mktemp failed" >&2; exit 1; } -[ -n "$WORK" ] && [ -d "$WORK" ] || { echo "FATAL: bad WORK" >&2; exit 1; } +if [ -z "$WORK" ] || [ ! -d "$WORK" ]; then echo "FATAL: bad WORK" >&2; exit 1; fi trap 'rm -rf "$WORK"' EXIT # Copy tracked files only — no .git, no run state. diff --git a/tests/oracle-gate.sh b/tests/oracle-gate.sh index fa883fa..ea11825 100644 --- a/tests/oracle-gate.sh +++ b/tests/oracle-gate.sh @@ -23,7 +23,7 @@ command -v jq >/dev/null || { echo "FATAL: jq required" >&2; exit 1; } command -v sha256sum >/dev/null || { echo "FATAL: sha256sum required" >&2; exit 1; } WORK=$(mktemp -d) || { echo "FATAL: mktemp failed" >&2; exit 1; } -[ -n "$WORK" ] && [ -d "$WORK" ] || { echo "FATAL: bad WORK" >&2; exit 1; } +if [ -z "$WORK" ] || [ ! -d "$WORK" ]; then echo "FATAL: bad WORK" >&2; exit 1; fi trap 'rm -rf "$WORK"' EXIT hash_file() { sha256sum "$1" | cut -d' ' -f1; } diff --git a/tests/simple-test.sh b/tests/simple-test.sh index f83cf87..1b18742 100644 --- a/tests/simple-test.sh +++ b/tests/simple-test.sh @@ -54,7 +54,7 @@ test_skip() { # Create temp directory TEST_TEMP=$(mktemp -d) || { echo "FATAL: mktemp failed" >&2; exit 1; } -[ -n "$TEST_TEMP" ] && [ -d "$TEST_TEMP" ] || { echo "FATAL: bad TEST_TEMP" >&2; exit 1; } +if [ -z "$TEST_TEMP" ] || [ ! -d "$TEST_TEMP" ]; then echo "FATAL: bad TEST_TEMP" >&2; exit 1; fi trap 'rm -rf "$TEST_TEMP"' EXIT echo "========================================" diff --git a/tests/spec-map.sh b/tests/spec-map.sh index 864ad0b..b58a6f3 100644 --- a/tests/spec-map.sh +++ b/tests/spec-map.sh @@ -11,7 +11,7 @@ SPEC="$SCRIPT_DIR/BEHAVIOR-SPEC.md" MODE="${1:-validate}" WORK=$(mktemp -d) || { echo "FATAL: mktemp failed" >&2; exit 1; } -[ -n "$WORK" ] && [ -d "$WORK" ] || { echo "FATAL: bad WORK" >&2; exit 1; } +if [ -z "$WORK" ] || [ ! -d "$WORK" ]; then echo "FATAL: bad WORK" >&2; exit 1; fi trap 'rm -rf "$WORK"' EXIT # Runtime names, from an actual run. Strip ANSI, match the three verdicts,