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

critcheck does not recognise BSD grep's regex errors, so malformed checks count as failures on macOS

Open AbirAbbas opened this issue 3 weeks ago • 0 comments

What happened

On macOS 15.6 (arm64), TestAMalformedCheckWithNoRepairIsNotCounted in go/internal/critcheck fails (critcheck_test.go:114: findings = []), on main as well. It is a product gap, not only a test: on macOS a grep acceptance criterion with a malformed regular expression is counted as a real failure instead of "not counted".

Replication

On a Mac: cd go && go test ./internal/critcheck -run TestAMalformedCheckWithNoRepairIsNotCounted -count=1 -v. By hand: grep -E 'Checksum(' /dev/null; echo $? prints grep: parentheses not balanced and exits 2.

Where

go/internal/critcheck/critcheck.go: Malformed() matches the grep/rg error signature, which knows GNU grep's wording ("Unmatched …", "Invalid …", "Trailing backslash"). BSD grep, the default on macOS, words regex errors differently: "parentheses not balanced", "brackets ([ ]) not balanced", lowercase "trailing backslash". Its option errors ("unrecognized option") are still caught.

The fix

Recognise BSD grep's regex error wording as well (or classify by exit status 2 plus a regex-shaped message), so a malformed pattern is "not counted" on both platforms.

Acceptance

The test passes on macOS and Linux, and a criterion grep -E 'Checksum(' <file> is reported as not counted on both.

AbirAbbas avatar Nov 13 '26 00:11 AbirAbbas