Skip to content

fix(test): §79 macOS/BSD portability — awk $-anchor + wc leading whitespace - #69

Merged
rappdw merged 1 commit into
mainfrom
fix/79-macos-bsd-portability
Jul 23, 2026
Merged

fix(test): §79 macOS/BSD portability — awk $-anchor + wc leading whitespace#69
rappdw merged 1 commit into
mainfrom
fix/79-macos-bsd-portability

Conversation

@rappdw

@rappdw rappdw commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Three §79 (sandy --gc) checks pass in CI (Ubuntu/GNU) but fail on a macOS host. Both root causes are BSD-vs-GNU userland differences in the test harness only — the sandy --gc product code is unaffected (every per-container identity assertion passed on macOS; only these three broke):

Failing check Cause Fix
"parses its OWN --dry-run/--yes into distinct locals" macOS BWK awk treats \$ as the $ anchor (drops the backslash) → the region-start regex has an anchor mid-pattern → never matches → empty region → grep fails rewrite start pattern to /^if .*--gc/ (no literal $)
"plan step also uses 'reap' mode" same (shares the extraction) same
"reaped exactly the 5 expected dead-owner containers" BSD wc -l emits leading whitespace (   5) even when piped → grep -qx 5 whole-line match fails [ "$(… | wc -l | tr -d ' ')" = 5 ]

Verification

  • Both structural checks pass under mawk (BSD-regex proxy) and default awk, extracting the identical 143-line region; /^if .*--gc/ matches exactly the one dispatcher line.
  • The count fix handles leading-whitespace wc.
  • Swept the suite: no other \${1:-}-in-awk or wc -l \| grep -qx traps remain.
  • bash -n clean.

Test-only; no product-code change. This is the same class as the earlier _BASE_BUILD_Q / sleep infinity macOS breaks — CI (GNU) can't catch them; surfaced by a maintainer host run.

🤖 Generated with Claude Code

…tespace

Three §79 (`sandy --gc`) checks passed in CI (Ubuntu/GNU) but failed on a
macOS host. Both root causes are BSD-userland vs GNU differences in the TEST
harness only — the sandy --gc product code is unaffected (every per-container
identity assertion passed on macOS; only these three broke):

1/2. The two structural checks extracting the --gc dispatcher block used
   `awk "/^if \[\[ \"\${1:-}\" == \"--gc\" \]\]; then/,/^fi$/"`. macOS's BWK awk
   ("the one true awk") treats `\$` as the `$` end-of-line ANCHOR (dropping the
   backslash) rather than a literal `$`, putting an anchor mid-pattern so the
   range start never matches → empty region → the greps for
   `_sandy_gc_dry_run` / `_sandy_dead_owner_containers_list reap` fail. GNU awk
   and mawk treat `\$` as a literal `$`, so CI passed. Rewrote the start pattern
   to `/^if .*--gc/` (no literal `$`), which matches exactly the one dispatcher
   line and extracts the identical 143-line region on gawk/mawk/BWK awk.

3. `sort -u "$1" | wc -l | grep -qx 5` — BSD `wc -l` emits leading whitespace
   (`       5`) even when piped, so the whole-line match `grep -qx 5` fails on
   macOS. Replaced with `[ "$(... | wc -l | tr -d ' ')" = 5 ]`.

Verified: both structural checks pass under mawk (BSD regex proxy); the count
fix handles leading-whitespace wc. No other `\${1:-}`-in-awk or
`wc -l | grep -qx` traps remain in the suite.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@rappdw
rappdw merged commit af5566c into main Jul 23, 2026
2 checks passed
@rappdw
rappdw deleted the fix/79-macos-bsd-portability branch July 23, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant