@@ -119,24 +119,27 @@ runs:
119119 # Initialize JSON array for structured failures with signatures
120120 echo '[]' > "$signatures_file"
121121
122+ # Define common test validation filter to avoid duplication
123+ local test_failure_filter='select(.Action == "fail" and .Test != null and .Test != "" and .Test != "null" and (.Test | test("^Test[A-Za-z]")))'
124+
122125 # Fast single-pass JSON extraction for test failures (< 1s for 10K lines)
123126 # Filter JSON lines and parse in one pass - eliminates 2-minute hang
124127 # Note: Line numbers aren't available in Go test JSON output
125128 # IMPORTANT: Only detect actual test function failures, not package/suite completion events
126129 grep '^{' "$json_file" 2>/dev/null | \
127- jq -r 'select(.Action == "fail" and .Test != null and .Test != "" and .Test != "null" and (.Test | test("^Test[A-Za-z]"))) |
130+ jq -r "$test_failure_filter"' |
128131 "--- FAIL: \(.Test) (\(.Package))"' \
129132 2>/dev/null > "$failures_file"
130133
131134 # Create structured test failure entries with unique signatures
132- if grep '^{' "$json_file" 2>/dev/null | jq -r 'select(.Action == "fail" and .Test != null and .Test != "" and .Test != "null" and (.Test | test("^Test[A-Za-z]")))' 2>/dev/null | head -1 | grep -q .; then
135+ if grep '^{' "$json_file" 2>/dev/null | jq -r "$test_failure_filter" 2>/dev/null | head -1 | grep -q .; then
133136 echo "📝 Creating structured test failure entries with enhanced output..."
134137
135138 # First pass: Extract test failure basic info from Action == "fail" entries
136139 local temp_failures
137140 temp_failures=$(mktemp)
138141 grep '^{' "$json_file" 2>/dev/null | \
139- jq -r 'select(.Action == "fail" and .Test != null and .Test != "" and .Test != "null" and (.Test | test("^Test[A-Za-z]"))) | {
142+ jq -r "$test_failure_filter"' | {
140143 type: "test",
141144 package: .Package,
142145 test: (if (.Test and .Test != null and .Test != "null") then .Test else "unknown" end),
0 commit comments