MCPcopy Create free account
hub / github.com/FastLED/FastLED / format_test_summary

Function format_test_summary

ci/debug_attached.py:326–374  ·  view source on GitHub ↗

Format RESULT JSON events into compact test summary. Extracts meaningful test results from the RESULT JSON lines emitted by the AutoResearch firmware and formats them into a concise summary. Args: result_events: List of parsed RESULT JSON events Returns: Formatted

(result_events: list[dict[str, Any]])

Source from the content-addressed store, hash-verified

324
325
326def format_test_summary(result_events: list[dict[str, Any]]) -> str:
327 """Format RESULT JSON events into compact test summary.
328
329 Extracts meaningful test results from the RESULT JSON lines emitted by
330 the AutoResearch firmware and formats them into a concise summary.
331
332 Args:
333 result_events: List of parsed RESULT JSON events
334
335 Returns:
336 Formatted summary string, or empty string if no results
337 """
338 if not result_events:
339 return ""
340
341 # Find case_result events (one per test case)
342 case_results = [e for e in result_events if e.get("type") == "case_result"]
343
344 if not case_results:
345 return ""
346
347 # Extract info from first case (they should all be same driver)
348 first = case_results[0]
349 driver = first.get("driver", "Unknown")
350 lanes = first.get("laneCount", 1)
351 strip_size = first.get("stripSize", 0)
352
353 total_tests = sum(c.get("totalTests", 0) for c in case_results)
354 passed_tests = sum(c.get("passedTests", 0) for c in case_results)
355 all_passed = all(c.get("passed", False) for c in case_results)
356
357 # Build compact summary
358 lane_str = "lane" if lanes == 1 else "lanes"
359 lines = [
360 f"{driver} Driver Test Results",
361 f" Config {lanes} {lane_str} × {strip_size} LEDs",
362 f" Patterns {total_tests} bit patterns tested",
363 ]
364
365 if all_passed:
366 lines.append(f" Tests {passed_tests}/{total_tests} PASSED")
367 else:
368 failed = total_tests - passed_tests
369 mismatch_str = "mismatch" if failed == 1 else "mismatches"
370 lines.append(
371 f" Tests {passed_tests}/{total_tests} FAILED ({failed} {mismatch_str})"
372 )
373
374 return "\n".join(lines)
375
376
377@dataclass(slots=True)

Callers 1

run_monitorFunction · 0.85

Calls 3

allFunction · 0.85
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected