From 558b1518b586cbf3ce5517d9a8be392ea029ae60 Mon Sep 17 00:00:00 2001 From: Marty Date: Tue, 20 Jan 2026 21:34:00 +0000 Subject: [PATCH] fix(tests): add --version handler to mock claude commands in prd_import tests Mock claude commands in test_prd_import.bats were hanging on test 240 because they started with 'cat > /dev/null' which blocks waiting for stdin. When ralph_import.sh calls 'claude --version' during dependency check, no stdin is provided, causing indefinite hang. Changes: - Added --version flag handler to all 7 mock claude command generators - Handler returns "Claude Code CLI version 2.0.80" and exits before stdin read - Fixes hang in test 240 and ensures all 33 prd_import tests pass This fix allows the quickstart installation to complete successfully without test stalls. Fixes #N/A (discovered during quickstart installation) --- tests/integration/test_prd_import.bats | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/integration/test_prd_import.bats b/tests/integration/test_prd_import.bats index 2787020..6240121 100644 --- a/tests/integration/test_prd_import.bats +++ b/tests/integration/test_prd_import.bats @@ -105,6 +105,13 @@ create_mock_claude_success() { cat > "$MOCK_BIN_DIR/claude" << 'MOCK_CLAUDE_EOF' #!/bin/bash # Mock Claude Code CLI that creates expected output files + +# Handle --version flag first (before reading stdin) +if [[ "$1" == "--version" ]]; then + echo "Claude Code CLI version 2.0.80" + exit 0 +fi + # Read from stdin (conversion prompt) cat > /dev/null @@ -255,6 +262,13 @@ create_mock_claude_failure() { cat > "$MOCK_BIN_DIR/claude" << 'MOCK_CLAUDE_FAIL_EOF' #!/bin/bash # Mock Claude Code CLI that fails + +# Handle --version flag first +if [[ "$1" == "--version" ]]; then + echo "Claude Code CLI version 2.0.80" + exit 0 +fi + echo "Error: Mock Claude Code failed" exit 1 MOCK_CLAUDE_FAIL_EOF @@ -699,6 +713,13 @@ create_mock_claude_json_success() { cat > "$MOCK_BIN_DIR/claude" << 'MOCK_CLAUDE_JSON_EOF' #!/bin/bash # Mock Claude Code CLI that outputs JSON format and creates expected files + +# Handle --version flag first +if [[ "$1" == "--version" ]]; then + echo "Claude Code CLI version 2.0.80" + exit 0 +fi + # Read from stdin (conversion prompt) cat > /dev/null @@ -776,6 +797,13 @@ create_mock_claude_json_partial() { cat > "$MOCK_BIN_DIR/claude" << 'MOCK_CLAUDE_PARTIAL_EOF' #!/bin/bash # Mock Claude Code CLI that outputs JSON but only creates some files + +# Handle --version flag first +if [[ "$1" == "--version" ]]; then + echo "Claude Code CLI version 2.0.80" + exit 0 +fi + cat > /dev/null # Only create PROMPT.md (missing @fix_plan.md and specs/requirements.md) @@ -811,6 +839,13 @@ create_mock_claude_json_error() { cat > "$MOCK_BIN_DIR/claude" << 'MOCK_CLAUDE_JSON_ERROR_EOF' #!/bin/bash # Mock Claude Code CLI that outputs JSON error response + +# Handle --version flag first +if [[ "$1" == "--version" ]]; then + echo "Claude Code CLI version 2.0.80" + exit 0 +fi + cat > /dev/null # Output JSON error response @@ -838,6 +873,13 @@ create_mock_claude_text_output() { cat > "$MOCK_BIN_DIR/claude" << 'MOCK_CLAUDE_TEXT_EOF' #!/bin/bash # Mock Claude Code CLI that outputs text (older CLI version) + +# Handle --version flag first +if [[ "$1" == "--version" ]]; then + echo "Claude Code CLI version 2.0.80" + exit 0 +fi + cat > /dev/null # Create files @@ -1057,6 +1099,13 @@ CAPTURE_ARGS_EOF @test "ralph-import handles malformed JSON and falls back to text parsing" { cat > "$MOCK_BIN_DIR/claude" << 'MALFORMED_JSON_EOF' #!/bin/bash + +# Handle --version flag first +if [[ "$1" == "--version" ]]; then + echo "Claude Code CLI version 2.0.80" + exit 0 +fi + cat > /dev/null # Create files @@ -1097,6 +1146,13 @@ MALFORMED_JSON_EOF @test "ralph-import extracts specific error message from JSON error" { cat > "$MOCK_BIN_DIR/claude" << 'DETAILED_ERROR_EOF' #!/bin/bash + +# Handle --version flag first +if [[ "$1" == "--version" ]]; then + echo "Claude Code CLI version 2.0.80" + exit 0 +fi + cat > /dev/null # Output detailed JSON error