mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-23 20:29:06 -05:00
fix: count bundled gaps apart in each heading
cross_reference.py --emulator abuse printed "Gaps: 3 missing" above three [BUNDLED] files, then "0 missing (need to be sourced)" in the total. The heading and the total now read one count: bundled files appear as "N bundled", never among the missing.
This commit is contained in:
1 parent
c05d29d941
commit
ceb8b752e6
2 files changed
+34
-11
No files matched your search
+11
-11
@@ -809,11 +809,16 @@ def print_report(
|
||||
if gaps == 0 and not show_clean:
|
||||
continue
|
||||
|
||||
parts = []
|
||||
for key in ("bios", "data", "large_file", "missing"):
|
||||
count = data.get(f"gap_{key}", 0)
|
||||
if count:
|
||||
parts.append(f"{count} {key}")
|
||||
# Counted once, for the heading and the total alike: a file bundled
|
||||
# with its emulator is not one to source.
|
||||
emulator_bundled = sum(
|
||||
1 for g in data["gap_details"]
|
||||
if g.get("bundled") and g.get("source") == "missing"
|
||||
)
|
||||
counts = {key: data.get(f"gap_{key}", 0) for key in totals}
|
||||
counts["missing"] -= emulator_bundled
|
||||
counts["bundled"] = emulator_bundled
|
||||
parts = [f"{count} {key}" for key, count in counts.items() if count]
|
||||
status = ", ".join(parts) if parts else "OK"
|
||||
|
||||
systems = ", ".join(data["systems"])
|
||||
@@ -842,13 +847,8 @@ 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"
|
||||
)
|
||||
totals[key] += counts[key]
|
||||
bundled += emulator_bundled
|
||||
totals["missing"] -= emulator_bundled
|
||||
|
||||
print(f"\n{'=' * 60}")
|
||||
print(f"Total: {total_gaps} undeclared files across {scope}")
|
||||
|
||||
@@ -21,6 +21,7 @@ from cross_reference import ( # noqa: E402
|
||||
_build_supplemental_index,
|
||||
cross_reference,
|
||||
entry_source,
|
||||
print_report,
|
||||
)
|
||||
|
||||
|
||||
@@ -54,6 +55,28 @@ class GapReportSources(unittest.TestCase):
|
||||
self.assertEqual(entry_source({"name": "ending.mid", "sha1": other}, index), "bios")
|
||||
self.assertEqual(entry_source({"name": "ending.mid", "md5": "1" * 32}, index), "bios")
|
||||
|
||||
def test_the_heading_and_the_total_count_bundled_files_alike(self):
|
||||
"""abuse printed "Gaps: 3 missing" above three [BUNDLED] files and
|
||||
"0 missing (need to be sourced)" below."""
|
||||
import contextlib
|
||||
import io
|
||||
|
||||
report = {"abuse": {
|
||||
"emulator": "Abuse", "systems": [], "gaps": 3, "total_files": 3,
|
||||
"platform_covered": 0, "gap_missing": 3,
|
||||
"gap_details": [
|
||||
{"name": f"f{i}", "required": True, "source": "missing", "bundled": True,
|
||||
"note": ""}
|
||||
for i in range(3)
|
||||
],
|
||||
}}
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out:
|
||||
print_report(report)
|
||||
text = out.getvalue()
|
||||
self.assertIn("Gaps: 3 bundled", text)
|
||||
self.assertNotIn("3 missing", text)
|
||||
self.assertIn("0 missing (need to be sourced)", text)
|
||||
|
||||
def test_a_directory_does_not_stand_for_a_file(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
(Path(tmp) / "bios" / "cpcemu" / "ROM").mkdir(parents=True)
|
||||
|
||||
Reference in new issue
Block a user