test(hooks): surface bash failures in _shell_verdict helper

Assert returncode == 0 so a malformed case snippet fails fast with
stderr instead of silently returning an empty string. Addresses
Copilot review feedback on #2133.
This commit is contained in:
Rishet Mehra
2026-07-24 23:37:14 +01:00
committed by safishamsi
parent e1e041b09b
commit ce9ea7d7b4
+5
View File
@@ -440,6 +440,11 @@ def _shell_verdict(pattern: str, candidate: str) -> str:
["bash", "-c", f'case "$1" in\n{pattern}) echo REJECTED ;;\n*) echo ACCEPTED ;;\nesac', "_", candidate],
capture_output=True, text=True,
)
# Fail loudly on a malformed case snippet instead of returning "" and
# producing a confusing ACCEPTED/REJECTED mismatch downstream.
assert result.returncode == 0, (
f"bash exited {result.returncode} for pattern {pattern!r}: {result.stderr.strip()}"
)
return result.stdout.strip()