diff --git a/scripts/cross_reference.py b/scripts/cross_reference.py index c3051b97..e8d03340 100644 --- a/scripts/cross_reference.py +++ b/scripts/cross_reference.py @@ -739,6 +739,9 @@ def print_report( total_gaps = 0 totals: dict[str, int] = {"bios": 0, "data": 0, "large_file": 0, "missing": 0} + # A runtime component bundled with its emulator is left out of the + # collection by design, as verify and the gaps page say: not a file to find. + bundled = 0 for emu_name, data in sorted(report.items()): gaps = data["gaps"] @@ -764,6 +767,8 @@ def print_report( for g in data["gap_details"]: req = "*" if g["required"] else " " src = g.get("source", "missing").upper() + if g.get("bundled") and g.get("source") == "missing": + src = "BUNDLED" # One line per file: a note spanning lines fell to column 0 # between entries and read as an emulator heading. note = f": {' '.join(str(g['note']).split())}" if g["note"] else "" @@ -777,6 +782,12 @@ def print_report( total_gaps += gaps for key in totals: totals[key] += data.get(f"gap_{key}", 0) + emulator_bundled = sum( + 1 for g in data["gap_details"] + if g.get("bundled") and g.get("source") == "missing" + ) + bundled += emulator_bundled + totals["missing"] -= emulator_bundled print(f"\n{'=' * 60}") print(f"Total: {total_gaps} undeclared files across {scope}") @@ -784,6 +795,8 @@ def print_report( print(f" {available} available (bios: {totals['bios']}, data: {totals['data']}, " f"large_file: {totals['large_file']})") print(f" {totals['missing']} missing (need to be sourced)") + if bundled: + print(f" {bundled} bundled with their emulator, not collected") def main() -> None: diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 9f561451..5e937603 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -5304,5 +5304,28 @@ class TheTreeKeepsStandaloneEntries(unittest.TestCase): self.assertGreater(int(undeclared.group(1)), 0) +class TheCliSetsBundledFilesApart(unittest.TestCase): + """cross_reference counted daedalusx64's n64.psh and touchHLE's runtime + libraries as missing, to be sourced, though the project leaves them out + by design and verify and the gaps page already say so.""" + + def test_a_bundled_gap_is_not_missing(self): + from scripts.cross_reference import print_report + + gap = {"name": "n64.psh", "required": True, "bundled": True, "note": "", + "source": "missing"} + report = {"emu": { + "emulator": "Emu", "systems": [], "total_files": 1, "platform_covered": 0, + "gaps": 1, "gap_missing": 1, "gap_details": [gap], + }} + out = io.StringIO() + with contextlib.redirect_stdout(out): + print_report(report) + text = out.getvalue() + self.assertIn("0 missing (need to be sourced)", text) + self.assertIn("1 bundled with their emulator", text) + self.assertIn("n64.psh [BUNDLED]", text) + + if __name__ == "__main__": unittest.main()