File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -6,22 +6,26 @@ LOG="/tmp/e2e-output.log"
66python3 -c "
77import json, sys
88
9- # The JSON output is on stdout; the log may also contain stderr debug lines .
10- # Find the first line that parses as valid JSON .
9+ # The JSON output may be prefixed with a logger timestamp (e.g. '2026-04-08 22:46:50,580: {...}') .
10+ # Try parsing the full line first, then from the first '{' character .
1111found = False
1212with open('$LOG ') as f:
1313 for line in f:
1414 line = line.strip()
15- if not line:
16- continue
17- try:
18- data = json.loads(line)
19- if isinstance(data, dict):
20- found = True
21- print(f'PASS: Valid JSON output with {len(data)} top-level key(s)')
22- break
23- except json.JSONDecodeError:
15+ if not line or '{' not in line:
2416 continue
17+ # Try full line first, then from the first brace
18+ for candidate in (line, line[line.index('{'):]):
19+ try:
20+ data = json.loads(candidate)
21+ if isinstance(data, dict):
22+ found = True
23+ print(f'PASS: Valid JSON output with {len(data)} top-level key(s)')
24+ break
25+ except json.JSONDecodeError:
26+ continue
27+ if found:
28+ break
2529
2630if not found:
2731 print('FAIL: No valid JSON object found in output')
You can’t perform that action at this time.
0 commit comments