Summary
All test invocations in pr-review-fix-loop/tests/test-loop-scripts.sh use bash "$STOP_HOOK" 2>/dev/null, discarding all stderr. This means if the hook emits unexpected warnings, error banners, or crashes with a stack trace, the test will never see it.
Impact
- Hook failures (e.g.,
write_exit_reason "ERROR") have their stderr silently discarded in tests
- A hook that crashes with a meaningful error message passes the test if the assertion only checks stdout
- Debug output from
dbg() is invisible during test runs
Proposed Fix
Capture stderr to a variable and assert it is empty (or contains expected content):
STDERR_OUTPUT=$(hook_input "$TMPDIR/transcript.jsonl" | bash "$STOP_HOOK" 2>&1 1>/dev/null)
if [[ -n "$STDERR_OUTPUT" ]]; then
fail "Unexpected stderr: $STDERR_OUTPUT"
fi
Scope
~30 test invocations across the file. Consider a helper function:
run_hook() {
local transcript="$1"
HOOK_STDOUT=$(hook_input "$transcript" | bash "$STOP_HOOK" 2>"$TMPDIR/stderr.log")
HOOK_STDERR=$(cat "$TMPDIR/stderr.log")
}
Context
Identified during PR review loop on #37 (fix/stop-hook-infinite-loop). Classified as tech debt — not blocking any PR.
Files
pr-review-fix-loop/tests/test-loop-scripts.sh
Summary
All test invocations in
pr-review-fix-loop/tests/test-loop-scripts.shusebash "$STOP_HOOK" 2>/dev/null, discarding all stderr. This means if the hook emits unexpected warnings, error banners, or crashes with a stack trace, the test will never see it.Impact
write_exit_reason "ERROR") have their stderr silently discarded in testsdbg()is invisible during test runsProposed Fix
Capture stderr to a variable and assert it is empty (or contains expected content):
Scope
~30 test invocations across the file. Consider a helper function:
Context
Identified during PR review loop on #37 (fix/stop-hook-infinite-loop). Classified as tech debt — not blocking any PR.
Files
pr-review-fix-loop/tests/test-loop-scripts.sh