Skip to content

Tests suppress stderr with 2>/dev/null, hiding hook failures #39

Description

@dapi

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions