Skip to content

Commit d1e3199

Browse files
ZviBaratzclaude
andcommitted
fix: implement --json flag and consume SUMMARY_ENTRIES in field-test-runner
The --json flag was parsed but never checked, and SUMMARY_ENTRIES was populated but never consumed. Now --json prints structured JSON summary to stdout with per-extension breakdown, and summary.json includes the extensions array. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6feac7b commit d1e3199

File tree

1 file changed

+46
-15
lines changed

1 file changed

+46
-15
lines changed

scripts/field-test-runner.sh

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,34 @@ for idx in $(seq 0 $((EXT_COUNT - 1))); do
267267
echo ""
268268
done
269269

270-
# Print summary
271-
echo "================================================================"
272-
echo " Summary: $PROCESSED processed, $SKIPPED skipped, $CHANGED changed"
273-
echo " Totals: P:$TOTAL_PASS F:$TOTAL_FAIL W:$TOTAL_WARN S:$TOTAL_SKIP"
274-
echo "================================================================"
275-
276-
# Save summary JSON
277-
python3 -c "
278-
import json
270+
# Build summary JSON (used for both file output and --json flag)
271+
ENTRIES_JSON="$(python3 -c "
272+
import json, sys
273+
entries = []
274+
for line in sys.stdin:
275+
line = line.strip()
276+
if not line:
277+
continue
278+
parts = line.split('|')
279+
entries.append({
280+
'name': parts[0],
281+
'counts': {
282+
'pass': int(parts[1]),
283+
'fail': int(parts[2]),
284+
'warn': int(parts[3]),
285+
'skip': int(parts[4]),
286+
},
287+
'changed': parts[5] == 'true',
288+
'new': int(parts[6]),
289+
'resolved': int(parts[7]),
290+
'unannotated': int(parts[8]),
291+
})
292+
print(json.dumps(entries))
293+
" <<< "$(printf '%s\n' "${SUMMARY_ENTRIES[@]}")")"
294+
295+
SUMMARY_JSON="$(python3 -c "
296+
import json, sys
297+
extensions = json.loads(sys.argv[1])
279298
summary = {
280299
'timestamp': '$TIMESTAMP',
281300
'ego_lint_version': '$EGO_LINT_VERSION',
@@ -288,14 +307,26 @@ summary = {
288307
'warn': $TOTAL_WARN,
289308
'skip': $TOTAL_SKIP,
290309
},
310+
'extensions': extensions,
291311
'results_dir': '$RESULTS_DIR',
292312
}
293313
print(json.dumps(summary, indent=2))
294-
" > "$RESULTS_DIR/summary.json"
295-
296-
echo ""
297-
echo "Results saved to: $RESULTS_DIR/"
314+
" "$ENTRIES_JSON")"
315+
316+
echo "$SUMMARY_JSON" > "$RESULTS_DIR/summary.json"
317+
318+
if [[ "$OPT_JSON" == true ]]; then
319+
echo "$SUMMARY_JSON"
320+
else
321+
# Print human-readable summary
322+
echo "================================================================"
323+
echo " Summary: $PROCESSED processed, $SKIPPED skipped, $CHANGED changed"
324+
echo " Totals: P:$TOTAL_PASS F:$TOTAL_FAIL W:$TOTAL_WARN S:$TOTAL_SKIP"
325+
echo "================================================================"
326+
echo ""
327+
echo "Results saved to: $RESULTS_DIR/"
298328

299-
if [[ "$OPT_UPDATE_BASELINES" == true ]]; then
300-
echo "Baselines updated in: $BASELINES_DIR/"
329+
if [[ "$OPT_UPDATE_BASELINES" == true ]]; then
330+
echo "Baselines updated in: $BASELINES_DIR/"
331+
fi
301332
fi

0 commit comments

Comments
 (0)