Print a summary table of all test results.
(results: list[TestResult])
| 425 | |
| 426 | |
| 427 | def print_summary(results: list[TestResult]) -> None: |
| 428 | """Print a summary table of all test results.""" |
| 429 | print() |
| 430 | print(f"{'=' * 70}") |
| 431 | print(f" RESULTS SUMMARY") |
| 432 | print(f"{'=' * 70}") |
| 433 | print() |
| 434 | |
| 435 | # Header |
| 436 | print( |
| 437 | f" {'#':<3} {'Status':<8} {'Driver':<10} {'Lanes':<6} {'Base':<6} {'Sizes':<15} {'API':<8} {'Tests':<10} {'Time':<10} {'Error'}" |
| 438 | ) |
| 439 | print( |
| 440 | f" {'-' * 3} {'-' * 8} {'-' * 10} {'-' * 6} {'-' * 6} {'-' * 15} {'-' * 8} {'-' * 10} {'-' * 10} {'-' * 20}" |
| 441 | ) |
| 442 | |
| 443 | passed_count = 0 |
| 444 | failed_count = 0 |
| 445 | |
| 446 | for i, r in enumerate(results, 1): |
| 447 | tc = r.test_case |
| 448 | status = "PASS" if r.passed else "FAIL" |
| 449 | sizes_str = ",".join(str(s) for s in tc.lane_sizes) |
| 450 | api = "legacy" if tc.use_legacy_api else "channel" |
| 451 | tests_str = f"{r.passed_tests}/{r.total_tests}" if r.total_tests > 0 else "-" |
| 452 | time_str = f"{r.duration_ms}ms" if r.duration_ms > 0 else "-" |
| 453 | error_str = (r.error or "")[:40] |
| 454 | |
| 455 | if r.passed: |
| 456 | passed_count += 1 |
| 457 | else: |
| 458 | failed_count += 1 |
| 459 | |
| 460 | print( |
| 461 | f" {i:<3} {status:<8} {tc.driver:<10} {tc.lane_count:<6} {tc.base_led_count:<6} {sizes_str:<15} {api:<8} {tests_str:<10} {time_str:<10} {error_str}" |
| 462 | ) |
| 463 | |
| 464 | print() |
| 465 | total = len(results) |
| 466 | print(f" Total: {total} tests | Passed: {passed_count} | Failed: {failed_count}") |
| 467 | |
| 468 | if failed_count > 0: |
| 469 | print(f"\n FAILED TESTS:") |
| 470 | for i, r in enumerate(results, 1): |
| 471 | if not r.passed: |
| 472 | print(f" [{i}] {r.test_case.label}: {r.error}") |
| 473 | |
| 474 | print() |
| 475 | if failed_count == 0: |
| 476 | print(" ALL TESTS PASSED") |
| 477 | else: |
| 478 | print(f" {failed_count} TEST(S) FAILED") |
| 479 | print(f"{'=' * 70}") |
| 480 | |
| 481 | |
| 482 | def main() -> int: |