diff options
Diffstat (limited to 'tests/claude-code/test-helpers.sh')
| -rwxr-xr-x | tests/claude-code/test-helpers.sh | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/claude-code/test-helpers.sh b/tests/claude-code/test-helpers.sh index 1b5ead3..ef1315a 100755 --- a/tests/claude-code/test-helpers.sh +++ b/tests/claude-code/test-helpers.sh @@ -7,7 +7,8 @@ run_claude() { local prompt="$1" local timeout="${2:-60}" local allowed_tools="${3:-}" - local output_file=$(mktemp) + local output_file + output_file="$(mktemp)" # Build command as an argv array so timeout wraps claude directly. local cmd=(claude -p "$prompt") @@ -74,7 +75,8 @@ assert_count() { local expected="$3" local test_name="${4:-test}" - local actual=$(echo "$output" | grep -c "$pattern" || echo "0") + local actual + actual="$(echo "$output" | grep -c "$pattern" || true)" if [ "$actual" -eq "$expected" ]; then echo " [PASS] $test_name (found $actual instances)" @@ -98,8 +100,10 @@ assert_order() { local test_name="${4:-test}" # Get line numbers where patterns appear - local line_a=$(echo "$output" | grep -n "$pattern_a" | head -1 | cut -d: -f1) - local line_b=$(echo "$output" | grep -n "$pattern_b" | head -1 | cut -d: -f1) + local line_a + local line_b + line_a="$(echo "$output" | grep -n "$pattern_a" | head -1 | cut -d: -f1 || true)" + line_b="$(echo "$output" | grep -n "$pattern_b" | head -1 | cut -d: -f1 || true)" if [ -z "$line_a" ]; then echo " [FAIL] $test_name: pattern A not found: $pattern_a" @@ -125,7 +129,8 @@ assert_order() { # Create a temporary test project directory # Usage: test_project=$(create_test_project) create_test_project() { - local test_dir=$(mktemp -d) + local test_dir + test_dir="$(mktemp -d)" echo "$test_dir" } |
