SWE-AF icon indicating copy to clipboard operation
SWE-AF copied to clipboard

critcheck counts a malformed grep pattern as a failure on macOS (BSD grep error wording)

Open AbirAbbas opened this issue 3 weeks ago • 1 comments

What happened

On macOS a grep acceptance criterion with a malformed regular expression is counted as a real failure instead of "not counted", because macOS's BSD grep words its errors differently from GNU grep. go/internal/critcheck TestAMalformedCheckWithNoRepairIsNotCounted fails on macOS on main (critcheck_test.go:114: findings = []) and passes on Linux.

Replication

On a Mac: cd go && go test ./internal/critcheck -run TestAMalformedCheckWithNoRepairIsNotCounted -count=1 -v. By hand: echo x | grep -E 'Checksum(' prints grep: parentheses not balanced (exit 2) with BSD grep.

Where

Malformed() (go/internal/critcheck/critcheck.go) matches GNU's regex error wording ("Unmatched …", "Invalid …", "Trailing backslash"). BSD grep says "parentheses not balanced", "brackets ([ ]) not balanced" and lowercase "trailing backslash". Option errors ("unrecognized option") are already caught.

The fix

Recognise the BSD grep regex error messages alongside the GNU ones.

Acceptance

On macOS and Linux, a criterion whose grep pattern is malformed is reported as not counted, and the existing test passes on both.

AbirAbbas avatar Nov 13 '26 00:11 AbirAbbas

Duplicate of #192, which has the fuller write-up. Filed twice by mistake during the 2026-11-13 macOS check (PR #194 references both).

AbirAbbas avatar Nov 16 '26 13:11 AbirAbbas