From 72ee5bbc5e489dc9c76fa64ba0fc31ab85185238 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 13 Aug 2026 00:32:39 +0000 Subject: [PATCH] tests: redirect stdin from /dev/null when spawning claude CLI run_claude ran `timeout "$timeout" "${cmd[@]}"` with the suite's stdin inherited by the spawned CLI. When the suite is run from a terminal (or any open stdin), claude -p can block reading stdin and each test stalls for its full timeout instead of completing. Verified deterministically with a stub `claude` that reads stdin (cat): with an open stdin pipe the old helper blocks until timeout kills it (exit 124); with the redirect it exits immediately with output. Part of #2130; defect documented in PR #2071 by @ericyen97903-lab. --- tests/claude-code/test-helpers.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/claude-code/test-helpers.sh b/tests/claude-code/test-helpers.sh index 9e187610..6dd4a558 100755 --- a/tests/claude-code/test-helpers.sh +++ b/tests/claude-code/test-helpers.sh @@ -15,8 +15,9 @@ run_claude() { cmd+=(--allowed-tools="$allowed_tools") fi - # Run Claude in headless mode with timeout - if timeout "$timeout" "${cmd[@]}" > "$output_file" 2>&1; then + # Run Claude in headless mode with timeout. Redirect stdin from + # /dev/null so the CLI can't block waiting for input and hang the suite. + if timeout "$timeout" "${cmd[@]}" > "$output_file" 2>&1 < /dev/null; then cat "$output_file" rm -f "$output_file" return 0