From 6b9300f6012432ed057ff7199d5bd854ac753cc0 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 18 Oct 2026 16:29:18 +0200 Subject: [PATCH] fix: report ground truth as the site does --- scripts/verify.py | 17 +++++++++++----- tests/test_audit_regressions.py | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/scripts/verify.py b/scripts/verify.py index 979e4cb8..f35713f6 100644 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -1478,13 +1478,20 @@ def print_platform_result( print(f" No external files: {len(exclusions)} cores (--verbose lists them)") gt_cov = result.get("ground_truth_coverage") - if gt_cov and gt_cov["total"] > 0: - pct = gt_cov["with_validation"] * 100 // gt_cov["total"] + if gt_cov and not gt_cov.get("applicable", True): + # MiSTer declares no core by design: its BiosDB is the answer, and + # the site shows "-" for it rather than a 0% gap. + print(" Ground truth: not applicable, the platform runs no profiled core") + elif gt_cov and gt_cov["total"] > 0: + # Rounded, as the site rounds: truncated, RetroArch read 20% here + # and 21% there for one measure. + pct = round(gt_cov["with_validation"] * 100 / gt_cov["total"]) print( f" Ground truth: {gt_cov['with_validation']}/{gt_cov['total']} files have emulator validation ({pct}%)" ) - if gt_cov["platform_only"]: - print(f" {gt_cov['platform_only']} platform-only (no emulator profile)") + no_profile = gt_cov["total"] - gt_cov.get("with_profile", gt_cov["with_validation"]) + if no_profile: + print(f" {no_profile} platform-only (no emulator profile)") # Emulator/system mode verification @@ -2077,7 +2084,7 @@ def print_emulator_result(result: dict, verbose: bool = False) -> None: # Ground truth coverage footer gt_cov = result.get("ground_truth_coverage") if gt_cov and gt_cov["total"] > 0: - pct = gt_cov["with_validation"] * 100 // gt_cov["total"] + pct = round(gt_cov["with_validation"] * 100 / gt_cov["total"]) print( f" Ground truth: {gt_cov['with_validation']}/{gt_cov['total']} files have emulator validation ({pct}%)" ) diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index fd8e81f4..371d79f1 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -5001,5 +5001,40 @@ class AFailedVerificationIsAnError(unittest.TestCase): self.assertIn('print(f"ERROR: packs failed verification: {\', \'.join(failing)}", file=sys.stderr)', source) + +class TheGroundTruthFooterSaysWhatItCounts(unittest.TestCase): + """"417 platform-only (no emulator profile)" where 369 of 526 files had + a profile; 20% here for 21% on the site; and "0/81 (0%)" for MiSTer, + which declares no core by design.""" + + def _footer(self, coverage): + import io as _io + from contextlib import redirect_stdout + + from scripts.verify import Severity, print_platform_result + + out = _io.StringIO() + counts = {Severity.OK: 1, Severity.INFO: 0, Severity.WARNING: 0, Severity.CRITICAL: 0} + result = {"platform": "X", "verification_mode": "existence", "total_files": 1, + "severity_counts": counts, "status_counts": {"ok": 1}, + "undeclared_files": [], "exclusion_notes": [], "details": [], + "ground_truth_coverage": coverage} + with redirect_stdout(out): + print_platform_result(result, ["X"]) + return out.getvalue() + + def test_counts_and_rounding(self): + text = self._footer({"with_validation": 109, "with_profile": 369, + "platform_only": 417, "total": 526, "applicable": True}) + self.assertIn("(21%)", text) + self.assertIn("157 platform-only", text) + + def test_not_applicable(self): + text = self._footer({"with_validation": 0, "with_profile": 0, + "platform_only": 81, "total": 81, "applicable": False}) + self.assertIn("not applicable", text) + self.assertNotIn("0/81", text) + + if __name__ == "__main__": unittest.main()