Skip to content

Commit a557d7b

Browse files
fix(ci): repair aspect_tests.sh grep-count bash bug (baseline rot) (#118)
## Summary Restores the `Aspect — Thread Safety + ABI Contract + SPDX` check to green. The check has been red on `main` for some time, gating every PR. ## Root cause ``` tests/aspect_tests.sh: line 77: [[: 0 0: syntax error in expression (error token is "0") ``` The pattern `has_export=$(grep -c 'pattern' file 2>/dev/null || echo "0")` is broken: `grep -c` always prints the count (including `0` for no matches) **and** exits non-zero when there are no matches. So `|| echo "0"` also fires, and `has_export` ends up `"0\n0"`. The next line — `[[ "$has_export" -gt 0 ]]` — chokes on the embedded newline in arithmetic context. ## Fix Swap `|| echo "0"` → `|| true` at all 4 call-sites (lines 74, 75, 98, 99). `grep -c` already prints `0` cleanly; the `|| true` just suppresses the exit code so `set -euo pipefail` doesn't abort the script. ## What's held out of this PR The companion `.github/workflows/e2e.yml` fix — bump Zig `0.15.0` → `0.15.1` (matches `.tool-versions`, retired upstream) and refresh the `denoland/setup-deno` SHA pin (`5fae568d…` no longer resolves; repointing to v2.0.4's `667a34cd…` SHA which `publish.yml` already uses) — is **held out** because the current OAuth token lacks the `workflow` scope GitHub requires for workflow-file edits. Will land in a follow-up PR once the token is rotated, or you can apply those 4 line-edits directly. The `governance / Language / package anti-pattern policy` failure is also red on main, but a parallel session is already diagnosing it under the Estate-drift-remediation 2026-05 campaign. Not touched here per `[[parallel-session-branch-drift]]`. ## Test plan - [x] `bash -n tests/aspect_tests.sh` — syntax clean. - [ ] CI runs `Aspect — Thread Safety + ABI Contract + SPDX` green on this PR. - [ ] No regression in the test's pass/fail logic for repos that *should* fail it (cartridges with C-ABI exports + no Mutex). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a60b942 commit a557d7b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tests/aspect_tests.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ for zigfile in "$zig_ffi_dir"/*.zig; do
7171
;;
7272
esac
7373

74-
has_export=$(grep -cP '(?:pub )?export fn' "$zigfile" 2>/dev/null || echo "0")
75-
has_mutex=$(grep -c 'Mutex' "$zigfile" 2>/dev/null || echo "0")
74+
has_export=$(grep -cP '(?:pub )?export fn' "$zigfile" 2>/dev/null || true)
75+
has_mutex=$(grep -c 'Mutex' "$zigfile" 2>/dev/null || true)
7676

7777
if [[ "$has_export" -gt 0 && "$has_mutex" -eq 0 ]]; then
7878
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
9595
fi
9696

9797
if [[ -n "$ffi_zig" ]]; then
98-
has_export=$(grep -c 'pub export fn' "$ffi_zig" 2>/dev/null || echo "0")
99-
has_mutex=$(grep -c 'Mutex' "$ffi_zig" 2>/dev/null || echo "0")
98+
has_export=$(grep -c 'pub export fn' "$ffi_zig" 2>/dev/null || true)
99+
has_mutex=$(grep -c 'Mutex' "$ffi_zig" 2>/dev/null || true)
100100

101101
if [[ "$has_export" -gt 0 && "$has_mutex" -eq 0 ]]; then
102102
fail "$cart_name FFI: $has_export exports, no Mutex"

0 commit comments

Comments
 (0)