From 66ad7e5ce836339193d32f1d4134cf39f6978537 Mon Sep 17 00:00:00 2001 From: hyperpolymath <6759885+hyperpolymath@users.noreply.github.com> Date: Wed, 20 May 2026 09:53:34 +0100 Subject: [PATCH] fix(ci): repair aspect_tests.sh grep-count bash bug (baseline rot) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `Aspect — Thread Safety + ABI Contract + SPDX` has been red on `main`, gating every PR on these lines: tests/aspect_tests.sh: line 77: [[: 0 0: syntax error in expression (error token is "0") Root cause: `grep -c 'pattern' file 2>/dev/null || echo "0"`. When `grep -c` finds zero matches it outputs `0` to stdout **and** exits non-zero, which then triggers `|| echo "0"` — `has_export` ends up `"0\n0"`, and `[[ "0\n0" -gt 0 ]]` chokes on the embedded newline in arithmetic context. Swapped the `|| echo "0"` for `|| true` on all four call-sites; `grep -c` already prints `0` cleanly, the `|| true` just suppresses the exit code for `set -euo pipefail`. Verification: `bash -n tests/aspect_tests.sh` clean. (The companion `.github/workflows/e2e.yml` fix — Zig 0.15.0 → 0.15.1 and the `denoland/setup-deno` SHA refresh — is held out because the current OAuth token lacks the `workflow` scope GitHub requires for workflow-file edits. Will land separately once the token is rotated or via a token with the right scope.) Out of scope and deliberately not touched: - `governance / Language / package anti-pattern policy` — also red on main, but a parallel session is already diagnosing it under the Estate-drift-remediation 2026-05 campaign (parent standards#66). Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/aspect_tests.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/aspect_tests.sh b/tests/aspect_tests.sh index 7e517537..75ed2a75 100755 --- a/tests/aspect_tests.sh +++ b/tests/aspect_tests.sh @@ -71,8 +71,8 @@ for zigfile in "$zig_ffi_dir"/*.zig; do ;; esac - has_export=$(grep -cP '(?:pub )?export fn' "$zigfile" 2>/dev/null || echo "0") - has_mutex=$(grep -c 'Mutex' "$zigfile" 2>/dev/null || echo "0") + has_export=$(grep -cP '(?:pub )?export fn' "$zigfile" 2>/dev/null || true) + has_mutex=$(grep -c 'Mutex' "$zigfile" 2>/dev/null || true) if [[ "$has_export" -gt 0 && "$has_mutex" -eq 0 ]]; then fail "$basename_zig has $has_export C-ABI exports but no Mutex" @@ -95,8 +95,8 @@ for cart_dir in "$PROJECT_DIR"/cartridges/*/ffi; do fi if [[ -n "$ffi_zig" ]]; then - has_export=$(grep -c 'pub export fn' "$ffi_zig" 2>/dev/null || echo "0") - has_mutex=$(grep -c 'Mutex' "$ffi_zig" 2>/dev/null || echo "0") + has_export=$(grep -c 'pub export fn' "$ffi_zig" 2>/dev/null || true) + has_mutex=$(grep -c 'Mutex' "$ffi_zig" 2>/dev/null || true) if [[ "$has_export" -gt 0 && "$has_mutex" -eq 0 ]]; then fail "$cart_name FFI: $has_export exports, no Mutex"