mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: site reads core file counts from verify
compute_coverage recounted the gap entries: one per entry, not one per pack path, with held-but-unplaced and bundled files counted missing. RetroArch read 7956 packed and 419 missing where verify says 7977 and 66. packs/shares.py holds the split both now read.
This commit is contained in:
1 parent
d1b0c77039
commit
2f9cfc8e8d
12 files changed
+168
-94
No files matched your search
+9
-66
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
from collections import Counter
|
||||
|
||||
from core.text import count_text
|
||||
from packs.shares import core_shares
|
||||
from packs.verdicts import Severity, Status
|
||||
from resolve.categories import BIOS
|
||||
from resolve.nativemode import reads_file_contents
|
||||
@@ -229,53 +230,6 @@ def _print_undeclared_entry(
|
||||
print(f" validates {'+'.join(checks)}")
|
||||
|
||||
|
||||
def split_undeclared(undeclared: list[dict]) -> tuple[list[dict], list[dict], list[dict]]:
|
||||
"""Game data, firmware the pack places, firmware it holds but cannot place.
|
||||
|
||||
Everything that is not game data is firmware the core loads, archives
|
||||
included: a bios_zip sat in neither list, so a required one that was
|
||||
missing was never printed.
|
||||
"""
|
||||
game_data = [u for u in undeclared if u.get("category", "bios") == "game_data"]
|
||||
firmware = [u for u in undeclared if u.get("category", "bios") != "game_data"]
|
||||
unplaced = [u for u in firmware if u["in_repo"] and not u.get("in_pack", True)]
|
||||
placed = [u for u in firmware if u.get("in_pack", True)]
|
||||
return game_data, placed, unplaced
|
||||
|
||||
|
||||
def pack_shares(result: dict) -> tuple[int, int]:
|
||||
"""The core files and the game data a platform's pack carries, by the report.
|
||||
|
||||
The builder's count, one file per pack path, when the platform pass
|
||||
replayed it. Counting entries said 1130 for RetroArch, 48 more than the
|
||||
pack holds: rom.key alone was claimed by three Amiga cores.
|
||||
"""
|
||||
packed = result.get("packed_extras")
|
||||
if packed is not None:
|
||||
return packed["bios"], packed["game_data"]
|
||||
game_data, bios_files, _unplaced = split_undeclared(result.get("undeclared_files", []))
|
||||
return (
|
||||
sum(1 for u in bios_files if u["in_repo"]),
|
||||
sum(1 for u in game_data if u["in_repo"] and u.get("in_pack", True)),
|
||||
)
|
||||
|
||||
|
||||
def core_required_missing(bios_files: list[dict]) -> list[dict]:
|
||||
"""Core files a core cannot run without, absent from the collection.
|
||||
|
||||
A file bundled with the emulator (DaedalusX64's n64.psh, the shader
|
||||
library its renderer installs beside the binary) arrives with it: the
|
||||
collection does not hold it by design, and listing it as missing sent
|
||||
readers after a file every install already has.
|
||||
"""
|
||||
return [
|
||||
u
|
||||
for u in bios_files
|
||||
if u["required"] and not u["in_repo"] and not u.get("hle_fallback")
|
||||
and not u.get("bundled")
|
||||
]
|
||||
|
||||
|
||||
def _repeated_names(entries: list[dict]) -> frozenset[str]:
|
||||
"""Names more than one of ``entries`` carries."""
|
||||
counts = Counter(u["name"] for u in entries)
|
||||
@@ -305,23 +259,12 @@ def _print_undeclared_section(result: dict, verbose: bool) -> None:
|
||||
if not undeclared and not (packed and any(packed.values())):
|
||||
return
|
||||
|
||||
game_data, bios_files, unplaced = split_undeclared(undeclared)
|
||||
|
||||
# A file installed with its emulator is never collected, firmware or
|
||||
# game data, required or not: cross_reference counts it apart. The
|
||||
# firmware already left the pack lists (_mark_unplaced), the game data
|
||||
# did not, and Abuse's three bundled data files read as missing.
|
||||
bundled = [u for u in undeclared if not u["in_repo"] and u.get("bundled")]
|
||||
game_data = [u for u in game_data if u["in_repo"] or not u.get("bundled")]
|
||||
|
||||
req_not_in_repo = core_required_missing(bios_files)
|
||||
req_hle_not_in_repo = [
|
||||
u
|
||||
for u in bios_files
|
||||
if u["required"] and not u["in_repo"] and u.get("hle_fallback")
|
||||
]
|
||||
opt_not_in_repo = [u for u in bios_files if not u["required"] and not u["in_repo"]]
|
||||
core_in_pack, gd_packed = pack_shares(result)
|
||||
shares = core_shares(result)
|
||||
bundled, unplaced, game_data = shares.bundled, shares.unplaced, shares.game_data
|
||||
req_not_in_repo = shares.required_missing
|
||||
req_hle_not_in_repo = shares.hle_missing
|
||||
opt_not_in_repo = shares.optional_missing
|
||||
core_in_pack, gd_packed = shares.in_pack, shares.game_data_packed
|
||||
core_missing_req = len(req_not_in_repo) + len(req_hle_not_in_repo)
|
||||
core_missing_opt = len(opt_not_in_repo)
|
||||
|
||||
@@ -363,8 +306,8 @@ def _print_undeclared_section(result: dict, verbose: bool) -> None:
|
||||
f"({_omission_reasons(unplaced)})")
|
||||
|
||||
if game_data or (packed and packed.get("game_data")):
|
||||
gd_missing = [u for u in game_data if not u["in_repo"]]
|
||||
gd_unplaced = [u for u in game_data if u["in_repo"] and not u.get("in_pack", True)]
|
||||
gd_missing = shares.game_data_missing
|
||||
gd_unplaced = shares.game_data_unplaced
|
||||
if gd_missing or gd_packed or gd_unplaced:
|
||||
listed = "" if verbose or not gd_missing else " (--verbose lists them)"
|
||||
print(f" Game data: {gd_packed} in pack, {len(gd_missing)} missing{listed}")
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
"""The files a platform's cores add to its pack, placed, held or missing, as verify counts them."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
|
||||
def split_undeclared(undeclared: list[dict]) -> tuple[list[dict], list[dict], list[dict]]:
|
||||
"""Game data, firmware the pack places, firmware it holds but cannot place.
|
||||
|
||||
Everything that is not game data is firmware the core loads, archives
|
||||
included: a bios_zip sat in neither list, so a required one that was
|
||||
missing was never printed.
|
||||
"""
|
||||
game_data = [u for u in undeclared if u.get("category", "bios") == "game_data"]
|
||||
firmware = [u for u in undeclared if u.get("category", "bios") != "game_data"]
|
||||
unplaced = [u for u in firmware if u["in_repo"] and not u.get("in_pack", True)]
|
||||
placed = [u for u in firmware if u.get("in_pack", True)]
|
||||
return game_data, placed, unplaced
|
||||
|
||||
|
||||
def pack_shares(result: dict) -> tuple[int, int]:
|
||||
"""The core files and the game data a platform's pack carries, by the report.
|
||||
|
||||
The builder's count, one file per pack path, when the platform pass
|
||||
replayed it. Counting entries said 1130 for RetroArch, 48 more than the
|
||||
pack holds: rom.key alone was claimed by three Amiga cores.
|
||||
"""
|
||||
packed = result.get("packed_extras")
|
||||
if packed is not None:
|
||||
return packed["bios"], packed["game_data"]
|
||||
game_data, bios_files, _unplaced = split_undeclared(result.get("undeclared_files", []))
|
||||
return (
|
||||
sum(1 for u in bios_files if u["in_repo"]),
|
||||
sum(1 for u in game_data if u["in_repo"] and u.get("in_pack", True)),
|
||||
)
|
||||
|
||||
|
||||
def core_required_missing(bios_files: list[dict]) -> list[dict]:
|
||||
"""Core files a core cannot run without, absent from the collection.
|
||||
|
||||
A file bundled with the emulator (DaedalusX64's n64.psh, the shader
|
||||
library its renderer installs beside the binary) arrives with it: the
|
||||
collection does not hold it by design, and listing it as missing sent
|
||||
readers after a file every install already has.
|
||||
"""
|
||||
return [
|
||||
u
|
||||
for u in bios_files
|
||||
if u["required"] and not u["in_repo"] and not u.get("hle_fallback")
|
||||
and not u.get("bundled")
|
||||
]
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CoreShares:
|
||||
"""One platform's core files and game data, sorted the way verify reports them."""
|
||||
|
||||
in_pack: int
|
||||
required_missing: list[dict]
|
||||
hle_missing: list[dict]
|
||||
optional_missing: list[dict]
|
||||
bundled: list[dict]
|
||||
unplaced: list[dict]
|
||||
game_data: list[dict]
|
||||
game_data_packed: int
|
||||
|
||||
@property
|
||||
def game_data_missing(self) -> list[dict]:
|
||||
return [u for u in self.game_data if not u["in_repo"]]
|
||||
|
||||
@property
|
||||
def game_data_unplaced(self) -> list[dict]:
|
||||
return [u for u in self.game_data if u["in_repo"] and not u.get("in_pack", True)]
|
||||
|
||||
@property
|
||||
def packed(self) -> int:
|
||||
"""Core files and game data the pack carries."""
|
||||
return self.in_pack + self.game_data_packed
|
||||
|
||||
@property
|
||||
def missing(self) -> int:
|
||||
"""Core files and game data the collection lacks, bundled ones apart."""
|
||||
return (len(self.required_missing) + len(self.hle_missing)
|
||||
+ len(self.optional_missing) + len(self.game_data_missing))
|
||||
|
||||
@property
|
||||
def held_unplaced(self) -> int:
|
||||
"""Core files and game data held but left out of the pack."""
|
||||
return len(self.unplaced) + len(self.game_data_unplaced)
|
||||
|
||||
|
||||
def core_shares(result: dict) -> CoreShares:
|
||||
"""What a verify result says of the files its cores add to the pack."""
|
||||
undeclared = result.get("undeclared_files", [])
|
||||
game_data, bios_files, unplaced = split_undeclared(undeclared)
|
||||
# A file installed with its emulator is never collected, firmware or
|
||||
# game data, required or not: cross_reference counts it apart. The
|
||||
# firmware already left the pack lists (_mark_unplaced), the game data
|
||||
# did not, and Abuse's three bundled data files read as missing.
|
||||
bundled = [u for u in undeclared if not u["in_repo"] and u.get("bundled")]
|
||||
game_data = [u for u in game_data if u["in_repo"] or not u.get("bundled")]
|
||||
in_pack, game_data_packed = pack_shares(result)
|
||||
return CoreShares(
|
||||
in_pack=in_pack,
|
||||
required_missing=core_required_missing(bios_files),
|
||||
hle_missing=[
|
||||
u for u in bios_files
|
||||
if u["required"] and not u["in_repo"] and u.get("hle_fallback")
|
||||
],
|
||||
optional_missing=[u for u in bios_files if not u["required"] and not u["in_repo"]],
|
||||
bundled=bundled,
|
||||
unplaced=unplaced,
|
||||
game_data=game_data,
|
||||
game_data_packed=game_data_packed,
|
||||
)
|
||||
@@ -5,7 +5,7 @@ from __future__ import annotations
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from packs.report import pack_shares
|
||||
from packs.shares import pack_shares
|
||||
from packs.verdicts import Severity, Status
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from core.text import count_text
|
||||
from packs.report import NOT_FIRMWARE, core_required_missing, discrepancy_keys, split_undeclared
|
||||
from packs.report import NOT_FIRMWARE, discrepancy_keys
|
||||
from packs.shares import core_required_missing, split_undeclared
|
||||
from packs.verdicts import Severity
|
||||
|
||||
|
||||
|
||||
+11
-19
@@ -14,6 +14,7 @@ from model.platforms import load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.registry import VERSIONS_FILE
|
||||
from packs.coverage import verify_platform
|
||||
from packs.shares import core_shares
|
||||
from packs.verdicts import blocking_missing
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from sitegen.install import display_name
|
||||
@@ -47,13 +48,11 @@ def compute_coverage(
|
||||
# a hash platform) is held, not packed.
|
||||
present = ok + untested - len(result.get("excluded_files", []))
|
||||
pct = (present / total * 100) if total > 0 else 0
|
||||
undeclared = result.get("undeclared_files", [])
|
||||
# Held is not packed: a file the platform has no folder for, or one below
|
||||
# a folder it lists flat, stays out of the pack the fraction describes.
|
||||
core_present = sum(
|
||||
1 for u in undeclared if u.get("in_repo") and u.get("in_pack", True)
|
||||
)
|
||||
core_missing = len(undeclared) - core_present
|
||||
# verify's own count of what the cores add: one file per pack path, held
|
||||
# but unplaced and installed-with-the-emulator files apart. Recounting
|
||||
# the gap entries here said 7956 packed and 419 missing for RetroArch,
|
||||
# where verify says 7977 and 66.
|
||||
shares = core_shares(result)
|
||||
# Files a profile marks unsourceable never reach the undeclared list, so
|
||||
# the gap they represent has to be counted back in.
|
||||
profiles = load_emulator_profiles(emulators_dir)
|
||||
@@ -63,10 +62,6 @@ def compute_coverage(
|
||||
for f in (profiles.get(emu) or {}).get("files", []) or []
|
||||
if f.get("unsourceable")
|
||||
}
|
||||
core_unsourceable = len(unsourceable_names)
|
||||
missing_names = unsourceable_names | {
|
||||
u.get("name", "") for u in undeclared if not u.get("in_repo")
|
||||
}
|
||||
return {
|
||||
"platform": display_name(config, platform_name),
|
||||
"total": total,
|
||||
@@ -79,13 +74,10 @@ def compute_coverage(
|
||||
},
|
||||
"present": present,
|
||||
"percentage": pct,
|
||||
"core_present": core_present,
|
||||
"core_missing": core_missing,
|
||||
"core_unsourceable": core_unsourceable,
|
||||
"missing_names": missing_names,
|
||||
"unsourceable_names": unsourceable_names,
|
||||
"pack_files": present + core_present,
|
||||
"total_missing": missing + core_missing,
|
||||
"core_present": shares.packed,
|
||||
"core_missing": shares.missing,
|
||||
"core_unplaced": shares.held_unplaced,
|
||||
"core_unsourceable": len(unsourceable_names),
|
||||
"mode": config.get("verification_mode", "existence"),
|
||||
# The gaps page badge: verify's count, never refiltered from details.
|
||||
"required_missing": blocking_missing(
|
||||
@@ -103,7 +95,7 @@ def compute_coverage(
|
||||
# stores it here and the second reads it back, instead of verifying every
|
||||
# platform twice (about a minute of the site build).
|
||||
COVERAGE_CACHE_DIR = REPO_ROOT / "tmp" / "coverage-cache"
|
||||
_COVERAGE_CACHE_FORMAT = "4"
|
||||
_COVERAGE_CACHE_FORMAT = "5"
|
||||
|
||||
|
||||
def _coverage_inputs(db_path: Path, platforms_dir: str, emulators_dir: str) -> str:
|
||||
|
||||
@@ -192,7 +192,7 @@ def _platform_export_rows(
|
||||
field: coverage.get(field, 0)
|
||||
for field in (
|
||||
"total", "present", "verified", "untested", "missing",
|
||||
"core_present", "core_missing", "core_unsourceable",
|
||||
"core_present", "core_missing", "core_unplaced", "core_unsourceable",
|
||||
)
|
||||
},
|
||||
"contract": contract,
|
||||
|
||||
@@ -435,8 +435,11 @@ def _pack_content_rows(coverages: dict) -> list[str]:
|
||||
rows = []
|
||||
for pname, cov in _by_platform_name(coverages):
|
||||
display = cov["platform"]
|
||||
# A file held but not placed is needed and not in the pack, yet not
|
||||
# missing. One installed with its emulator is not needed from us.
|
||||
core_total = (
|
||||
cov["core_present"] + cov["core_missing"] + cov["core_unsourceable"]
|
||||
cov["core_present"] + cov["core_missing"] + cov["core_unplaced"]
|
||||
+ cov["core_unsourceable"]
|
||||
)
|
||||
rows.append(
|
||||
f"| [{display}](platforms/{pname}.md) "
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ COMMANDS = {
|
||||
),
|
||||
"verify.py": (
|
||||
"packs/verdicts.py", "packs/gaps.py", "packs/coverage.py", "packs/emulatorcheck.py",
|
||||
"packs/report.py", "packs/verifyplatforms.py", "packs/verifysummary.py",
|
||||
"packs/report.py", "packs/shares.py", "packs/verifyplatforms.py", "packs/verifysummary.py",
|
||||
"packs/verifyoutput.py", "packs/strictgate.py", "packs/verifyoptions.py",
|
||||
"packs/verifyprint.py", "packs/runscope.py", "packs/verifyrun.py",
|
||||
),
|
||||
|
||||
@@ -5511,11 +5511,11 @@ class BundledFilesAreNotToSource(unittest.TestCase):
|
||||
|
||||
def test_verify_does_not_count_it_missing(self):
|
||||
from packs import verifysummary
|
||||
from packs import report as packs_report
|
||||
from packs import shares as packs_shares
|
||||
|
||||
entry = {"name": "n64.psh", "required": True, "in_repo": False,
|
||||
"category": "bios", "in_pack": True, "bundled": True}
|
||||
self.assertEqual(packs_report.core_required_missing([entry]), [])
|
||||
self.assertEqual(packs_shares.core_required_missing([entry]), [])
|
||||
summary = verifysummary.overall_summary(
|
||||
[({"severity_counts": {}, "undeclared_files": [entry]}, ["ROCKNIX"])]
|
||||
)
|
||||
|
||||
@@ -95,6 +95,7 @@ class SiteReferenceContracts(unittest.TestCase):
|
||||
"missing": 0,
|
||||
"core_present": 1,
|
||||
"core_missing": 0,
|
||||
"core_unplaced": 0,
|
||||
"core_unsourceable": 0,
|
||||
"details": [],
|
||||
}
|
||||
|
||||
@@ -301,7 +301,8 @@ class PlatformReferenceInWords(unittest.TestCase):
|
||||
details = [{"name": "f.bin", "status": "ok", "system": "sony-playstation"}]
|
||||
cov = {"platform": "RomM", "details": details, "total": 1, "verified": 1,
|
||||
"present": 1, "missing": 0, "untested": 0, "mode": "md5",
|
||||
"core_present": 0, "core_missing": 0, "core_unsourceable": 0,
|
||||
"core_present": 0, "core_missing": 0, "core_unplaced": 0,
|
||||
"core_unsourceable": 0,
|
||||
"config": {"hash_type": "md5", "hash_rule": "size_and_any_hash",
|
||||
"systems": {"sony-playstation": {"files": [{"name": "f.bin"}]}},
|
||||
"source": "https://github.com/o/r/tree/" + "a" * 40}}
|
||||
|
||||
@@ -103,7 +103,24 @@ class SlugPlatform(unittest.TestCase):
|
||||
"slugs", "platforms", self.db, emulators_dir="emulators"
|
||||
)
|
||||
self.assertEqual(coverage["core_present"], 0)
|
||||
self.assertEqual(coverage["core_missing"], 1)
|
||||
# Held, so not missing: verify prints it apart, and so does the site.
|
||||
self.assertEqual((coverage["core_missing"], coverage["core_unplaced"]), (0, 1))
|
||||
|
||||
def test_the_site_reads_verify_counts(self):
|
||||
# Recounted from the gap entries, the site said 7956 packed and 419
|
||||
# missing for RetroArch where verify said 7977 and 66.
|
||||
from packs.shares import core_shares
|
||||
from sitegen.coverage import compute_coverage
|
||||
|
||||
report = verify_platform(self.config, self.db, "emulators", self.profiles)
|
||||
shares = core_shares(report)
|
||||
coverage = compute_coverage(
|
||||
"slugs", "platforms", self.db, emulators_dir="emulators"
|
||||
)
|
||||
self.assertEqual(
|
||||
(coverage["core_present"], coverage["core_missing"], coverage["core_unplaced"]),
|
||||
(shares.packed, shares.missing, shares.held_unplaced),
|
||||
)
|
||||
|
||||
def test_the_manifest_says_why_it_is_absent(self):
|
||||
manifest = packs_manifest.generate_manifest(
|
||||
|
||||
Reference in new issue
Block a user