TDD log files and sidecar-to-log cross-validation.
(q, bug_count, bug_ids, tdd_data)
| 988 | |
| 989 | |
| 990 | def check_tdd_logs(q, bug_count, bug_ids, tdd_data): |
| 991 | """TDD log files and sidecar-to-log cross-validation.""" |
| 992 | print("[TDD Log Files]") |
| 993 | if bug_count <= 0: |
| 994 | info("Zero bugs — TDD log files not required") |
| 995 | return |
| 996 | |
| 997 | patches_dir = _resolve_artifact_path(q, "patches") |
| 998 | results_dir = _resolve_artifact_path(q, "results") |
| 999 | valid_tags = {"RED", "GREEN", "NOT_RUN", "ERROR"} |
| 1000 | |
| 1001 | red_found = 0 |
| 1002 | red_missing = 0 |
| 1003 | green_found = 0 |
| 1004 | green_missing = 0 |
| 1005 | green_expected = 0 |
| 1006 | red_bad_tag = 0 |
| 1007 | green_bad_tag = 0 |
| 1008 | |
| 1009 | for bid in bug_ids: |
| 1010 | red_log = results_dir / f"{bid}.red.log" |
| 1011 | if red_log.is_file(): |
| 1012 | red_found += 1 |
| 1013 | tag = read_first_line_stripped(red_log) |
| 1014 | if tag not in valid_tags: |
| 1015 | red_bad_tag += 1 |
| 1016 | else: |
| 1017 | red_missing += 1 |
| 1018 | |
| 1019 | fix_patch = first_file_matching(patches_dir, [f"{bid}-fix*.patch"]) |
| 1020 | if fix_patch is not None: |
| 1021 | green_expected += 1 |
| 1022 | green_log = results_dir / f"{bid}.green.log" |
| 1023 | if green_log.is_file(): |
| 1024 | green_found += 1 |
| 1025 | tag = read_first_line_stripped(green_log) |
| 1026 | if tag not in valid_tags: |
| 1027 | green_bad_tag += 1 |
| 1028 | else: |
| 1029 | green_missing += 1 |
| 1030 | |
| 1031 | if red_missing == 0 and red_found > 0: |
| 1032 | pass_(f"All {red_found} confirmed bug(s) have red-phase logs") |
| 1033 | elif red_found > 0: |
| 1034 | fail(f"{red_missing} confirmed bug(s) missing red-phase log (BUG-NNN.red.log)") |
| 1035 | else: |
| 1036 | fail("No red-phase logs found (every confirmed bug needs quality/results/BUG-NNN.red.log)") |
| 1037 | |
| 1038 | if green_expected > 0: |
| 1039 | if green_missing == 0: |
| 1040 | pass_(f"All {green_found} bug(s) with fix patches have green-phase logs") |
| 1041 | else: |
| 1042 | fail(f"{green_missing} bug(s) with fix patches missing green-phase log (BUG-NNN.green.log)") |
| 1043 | else: |
| 1044 | info("No fix patches found — green-phase logs not required") |
| 1045 | |
| 1046 | if red_bad_tag > 0: |
| 1047 | fail(f"{red_bad_tag} red-phase log(s) missing valid first-line status tag (expected RED/GREEN/NOT_RUN/ERROR)") |
no test coverage detected