Skip to content

Commit b70175f

Browse files
claudehyperpolymath
authored andcommitted
fix(tests): POSIX arithmetic in e2e; prune Zig build dirs in aspect
- tests/e2e/lifecycle_e2e.sh: replace ((PASS++))/((FAIL++))/((SKIP++)) with PASS=$((PASS+1)) etc. Under `set -euo pipefail` a post-increment of a 0-valued var returns exit 1 and aborted the script on the first check (same fix already present in the aspect test). - tests/aspect/cross_cutting_test.sh: prune .zig-cache/ and zig-out/ from the Zig SPDX `find` so a generated, header-less dependencies.zig left by `zig build` cannot skew the count when the test runs in an already-built tree. https://claude.ai/code/session_01GJatEm2TVFSTBEkKXmserJ
1 parent 5c7fbfa commit b70175f

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

tests/aspect/cross_cutting_test.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ idr_total=$(find "${JK_DIR}/src/abi" -name '*.idr' 2>/dev/null | wc -l)
2929
idr_spdx=$(grep -rl 'SPDX-License-Identifier' "${JK_DIR}/src/abi" --include='*.idr' 2>/dev/null | wc -l)
3030
check "Idris2 SPDX headers (${idr_spdx}/${idr_total})" "[ '${idr_spdx}' -eq '${idr_total}' ]"
3131

32-
zig_total=$(find "${JK_DIR}/ffi/zig" -name '*.zig' 2>/dev/null | wc -l)
33-
zig_spdx=$(grep -rl 'SPDX-License-Identifier' "${JK_DIR}/ffi/zig" --include='*.zig' 2>/dev/null | wc -l)
32+
# NB: prune Zig build artefacts (.zig-cache/, zig-out/) — `zig build` drops a
33+
# generated dependencies.zig in the cache with no SPDX header, which would
34+
# otherwise skew the count when this runs in a tree that has been built.
35+
zig_total=$(find "${JK_DIR}/ffi/zig" -type d \( -name '.zig-cache' -o -name 'zig-out' \) -prune -o -name '*.zig' -print 2>/dev/null | wc -l)
36+
zig_spdx=$(find "${JK_DIR}/ffi/zig" -type d \( -name '.zig-cache' -o -name 'zig-out' \) -prune -o -name '*.zig' -print 2>/dev/null | xargs -r grep -l 'SPDX-License-Identifier' 2>/dev/null | wc -l)
3437
check "Zig SPDX headers (${zig_spdx}/${zig_total})" "[ '${zig_spdx}' -eq '${zig_total}' ]"
3538

3639
# --- Forbidden Patterns ---

tests/e2e/lifecycle_e2e.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ SKIP=0
1313
TMPDIR="$(mktemp -d)"
1414
trap 'rm -rf "$TMPDIR"' EXIT
1515

16-
check() { if eval "$2"; then echo "[PASS] $1"; ((PASS++)); else echo "[FAIL] $1"; ((FAIL++)); fi; }
17-
skip() { echo "[SKIP] $1"; ((SKIP++)); }
16+
# NB: use POSIX arithmetic assignment, not ((PASS++)) — under `set -e` a
17+
# post-increment whose old value is 0 returns exit status 1 and kills the
18+
# script after the very first check (matches tests/aspect/cross_cutting_test.sh).
19+
check() { if eval "$2"; then echo "[PASS] $1"; PASS=$((PASS+1)); else echo "[FAIL] $1"; FAIL=$((FAIL+1)); fi; }
20+
skip() { echo "[SKIP] $1"; SKIP=$((SKIP+1)); }
1821

1922
echo "=== JanusKey E2E Lifecycle Test ==="
2023

0 commit comments

Comments
 (0)