mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 14:28:54 -06:00
fix: count unsourceable core files as verify does
This commit is contained in:
1 parent
94fbf8d386
commit
2e80ad0211
7 files changed
+122
-42
No files matched your search
+39
-22
@@ -14,7 +14,7 @@ from model.profiles import lists_files, load_emulator_profiles
|
||||
from model.systems import select_systems
|
||||
from packs import slots
|
||||
from packs.crossreflaunchers import launcher_reads_not_held
|
||||
from packs.gaps import find_exclusion_notes, find_undeclared_files
|
||||
from packs.gaps import find_exclusion_notes, scan_core_files
|
||||
from packs.verdicts import (
|
||||
RELEASE_ASSET_PENDING,
|
||||
Severity,
|
||||
@@ -651,6 +651,32 @@ def _region_pass(
|
||||
return region_drops, region_fallbacks, region_extra_dests
|
||||
|
||||
|
||||
def _narrowed(
|
||||
run: _PlatformRun,
|
||||
rows: list[dict],
|
||||
region_drops: set[str],
|
||||
region_extra_dests: dict[tuple[str, str, str], str],
|
||||
) -> list[dict]:
|
||||
"""The rows of the core walk a narrowed pack keeps, as the builder keeps them."""
|
||||
if run.system_filter:
|
||||
# A system pack carries the extras its systems own.
|
||||
from packs.extras import report_owned_by_systems
|
||||
|
||||
rows = report_owned_by_systems(rows, run.system_filter)
|
||||
if run.required_only:
|
||||
rows = [u for u in rows if u.get("required") is not False]
|
||||
if region_drops:
|
||||
rows = [
|
||||
u
|
||||
for u in rows
|
||||
if region_extra_dests.get(
|
||||
(u.get("emulator", ""), u.get("name", ""), u.get("path") or "")
|
||||
)
|
||||
not in region_drops
|
||||
]
|
||||
return rows
|
||||
|
||||
|
||||
def _platform_gaps(
|
||||
run: _PlatformRun,
|
||||
occupied: dict[str, str | None],
|
||||
@@ -658,9 +684,10 @@ def _platform_gaps(
|
||||
region_extra_dests: dict[tuple[str, str, str], str],
|
||||
validation_index: dict,
|
||||
validation_owners: dict[str, list[tuple[str, str]]],
|
||||
) -> tuple[list[dict], set[str], dict[str, str]]:
|
||||
) -> tuple[list[dict], set[str], dict[str, str], list[dict]]:
|
||||
"""The core files of the pack: the gap report as the builder narrows it,
|
||||
the destinations it fills, and the category of each."""
|
||||
the destinations it fills, the category of each, and the files of the
|
||||
pack a profile documents unsourceable."""
|
||||
config = run.config
|
||||
# Cross-reference undeclared files, called exactly as the builder calls
|
||||
# it: its declarations, not the enriched ones (a core file the platform
|
||||
@@ -668,7 +695,7 @@ def _platform_gaps(
|
||||
# such files in the RetroArch pack), and no names from inside archives
|
||||
# or data trees (a loose file whose name exists only as a member of
|
||||
# naomi2.zip was counted "in pack" while the builder shipped nothing).
|
||||
undeclared = find_undeclared_files(
|
||||
core_files = scan_core_files(
|
||||
config,
|
||||
run.emulators_dir,
|
||||
run.db,
|
||||
@@ -676,25 +703,11 @@ def _platform_gaps(
|
||||
target_cores=run.target_cores,
|
||||
declared_names=platform_declarations(config, run.db, enrich=False),
|
||||
)
|
||||
undeclared = core_files.undeclared
|
||||
# The builder's own pass reads the same report: computed once here and
|
||||
# handed over as it stands now, before the markings below.
|
||||
report_for_builder = [dict(u) for u in undeclared]
|
||||
if run.system_filter:
|
||||
# A system pack carries the extras its systems own.
|
||||
from packs.extras import report_owned_by_systems
|
||||
|
||||
undeclared = report_owned_by_systems(undeclared, run.system_filter)
|
||||
if run.required_only:
|
||||
undeclared = [u for u in undeclared if u.get("required") is not False]
|
||||
if region_drops:
|
||||
undeclared = [
|
||||
u
|
||||
for u in undeclared
|
||||
if region_extra_dests.get(
|
||||
(u.get("emulator", ""), u.get("name", ""), u.get("path") or "")
|
||||
)
|
||||
not in region_drops
|
||||
]
|
||||
undeclared = _narrowed(run, undeclared, region_drops, region_extra_dests)
|
||||
if run.required_only:
|
||||
# One member of a required set, as the builder keeps it.
|
||||
spares = core_file_spares(undeclared)
|
||||
@@ -715,7 +728,8 @@ def _platform_gaps(
|
||||
run.system_filter,
|
||||
run.required_only,
|
||||
))
|
||||
return undeclared, placed, placed_kind
|
||||
unsourceable = _narrowed(run, core_files.unsourceable, region_drops, region_extra_dests)
|
||||
return undeclared, placed, placed_kind, unsourceable
|
||||
|
||||
|
||||
def _profile_coverage(
|
||||
@@ -880,7 +894,7 @@ def verify_platform(
|
||||
shipped, occupied = _builder_placement(
|
||||
tally.packed_order, bool(config.get("case_insensitive_fs", False))
|
||||
)
|
||||
undeclared, placed, placed_kind = _platform_gaps(
|
||||
undeclared, placed, placed_kind, unsourceable = _platform_gaps(
|
||||
run, occupied, region_drops, region_extra_dests, validation_index,
|
||||
validation_owners,
|
||||
)
|
||||
@@ -943,6 +957,9 @@ def verify_platform(
|
||||
"excluded_files": excluded,
|
||||
"packed_extras": packed_extras,
|
||||
"undeclared_files": undeclared,
|
||||
# Files of the pack a profile documents unsourceable: needed, never
|
||||
# held, counted by the same walk as the undeclared ones.
|
||||
"unsourceable_files": unsourceable,
|
||||
# Reported apart, never scored: no severity, count or exit code reads it.
|
||||
"launcher_reads_not_held": launcher_reads_not_held(
|
||||
{config.get("_key", platform): config}, db, profiles, data_dir_registry
|
||||
|
||||
+48
-2
@@ -189,6 +189,9 @@ class _GapScan:
|
||||
# entry, the entry it is a claim on)): settled once every core is read.
|
||||
set_records: list[SetRecord] = field(default_factory=list)
|
||||
undeclared: list[dict] = field(default_factory=list)
|
||||
# Files the pack would carry that a profile documents unsourceable: one
|
||||
# per slot, as a gap is counted.
|
||||
unsourceable: list[dict] = field(default_factory=list)
|
||||
seen_files: set[tuple] = field(default_factory=set)
|
||||
# Key -> the entry reported for it. A later profile reading the same
|
||||
# requirement is kept on that entry rather than counted again: a pack
|
||||
@@ -241,6 +244,19 @@ class _GapScan:
|
||||
None if outer else self.declared_contents,
|
||||
)
|
||||
if verdict == "settled":
|
||||
if (f.get("unsourceable") and not duplicate
|
||||
and not outside_gap_scope(f, is_standalone)):
|
||||
self.unsourceable.append({
|
||||
"profile": emu_name,
|
||||
"emulator": layout.get("emulator", emu_name),
|
||||
"systems": entry_system_ids(f, layout),
|
||||
"system": f.get("system"),
|
||||
"name": fname,
|
||||
"path": dest,
|
||||
"required": f.get("required", False),
|
||||
"category": f.get("category", "bios"),
|
||||
"reason": f["unsourceable"],
|
||||
})
|
||||
self.seen_files.add(seen_key)
|
||||
if (self.launcher_layer and not f.get("unsourceable") and not outer
|
||||
and not f.get("unplaced")):
|
||||
@@ -472,6 +488,33 @@ def find_undeclared_files(
|
||||
platform_declarations. Pass the strict ones (YAML names only) when
|
||||
building packs so alias-only names still get packed.
|
||||
"""
|
||||
return scan_core_files(
|
||||
config, emulators_dir, db, emu_profiles, target_cores, data_names,
|
||||
include_all, declared_names,
|
||||
).undeclared
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class CoreFiles:
|
||||
"""The core files a platform leaves undeclared, and those a profile
|
||||
documents unsourceable, each read once by one walk of the cores."""
|
||||
|
||||
undeclared: list[dict]
|
||||
unsourceable: list[dict]
|
||||
|
||||
|
||||
def scan_core_files(
|
||||
config: dict,
|
||||
emulators_dir: str,
|
||||
db: dict,
|
||||
emu_profiles: dict | None = None,
|
||||
target_cores: set[str] | None = None,
|
||||
data_names: set[str] | None = None,
|
||||
include_all: bool = False,
|
||||
declared_names: Mapping[str, list[tuple[int | None, str]]] | None = None,
|
||||
) -> CoreFiles:
|
||||
"""find_undeclared_files, with the unsourceable files the same walk
|
||||
settles: under its mode, unread_on and slot rules, never recounted."""
|
||||
if declared_names is None:
|
||||
declared_names = platform_declarations(config, db)
|
||||
folded_slots = case_folded_slots(config, declared_names)
|
||||
@@ -528,8 +571,11 @@ def find_undeclared_files(
|
||||
|
||||
undeclared.extend(sorted(scan.archive_entries.values(), key=lambda e: e["name"]))
|
||||
|
||||
return _split_bundled_claims(
|
||||
_settle_core_sets(undeclared, scan.set_records, settled, profiles)
|
||||
return CoreFiles(
|
||||
_split_bundled_claims(
|
||||
_settle_core_sets(undeclared, scan.set_records, settled, profiles)
|
||||
),
|
||||
scan.unsourceable,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -13,12 +13,10 @@ from core.paths import DB_FILE, EMULATORS_DIR, REPO_ROOT
|
||||
from model import siteinputs
|
||||
from model.largefiles import LARGE_FILES_CACHE
|
||||
from model.platforms import load_platform_config
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.registry import load_data_dir_registry, versions_file_for
|
||||
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
|
||||
|
||||
|
||||
@@ -55,15 +53,6 @@ def compute_coverage(
|
||||
# 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)
|
||||
unsourceable_names = {
|
||||
f.get("name", "")
|
||||
for emu in resolve_platform_cores(config, profiles)
|
||||
for f in (profiles.get(emu) or {}).get("files", []) or []
|
||||
if f.get("unsourceable")
|
||||
}
|
||||
return {
|
||||
"platform": display_name(config, platform_name),
|
||||
"total": total,
|
||||
@@ -79,7 +68,9 @@ def compute_coverage(
|
||||
"core_present": shares.packed,
|
||||
"core_missing": shares.missing,
|
||||
"core_unplaced": shares.held_unplaced,
|
||||
"core_unsourceable": len(unsourceable_names),
|
||||
# Files a profile marks unsourceable never reach the undeclared list:
|
||||
# verify counts them apart, one per slot, under the same rules.
|
||||
"core_unsourceable": len(result.get("unsourceable_files", [])),
|
||||
"mode": config.get("verification_mode", "existence"),
|
||||
# The gaps page badge: verify's count, never refiltered from details.
|
||||
"required_missing": blocking_missing(
|
||||
|
||||
@@ -48,8 +48,7 @@ class CoverageReadsTheGivenProfiles(unittest.TestCase):
|
||||
return {"status_counts": {}, "severity_counts": {}, "verification_mode": "existence",
|
||||
"total_files": 0, "undeclared_files": [], "details": []}
|
||||
|
||||
with mock.patch.object(sitecoverage, "verify_platform", fake_verify), \
|
||||
mock.patch.object(sitecoverage, "load_emulator_profiles", return_value={}):
|
||||
with mock.patch.object(sitecoverage, "verify_platform", fake_verify):
|
||||
sitecoverage.compute_coverage(
|
||||
"retroarch", str(REPO_ROOT / "platforms"), {"files": {}}, emulators_dir="elsewhere"
|
||||
)
|
||||
|
||||
@@ -162,9 +162,10 @@ class TheGapReportIsComputedOnce(unittest.TestCase):
|
||||
db = load_database("database.json")
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
config = load_platform_config("emudeck", "platforms")
|
||||
# find_undeclared_files is the same walk: counted through it too.
|
||||
with mock.patch.object(
|
||||
gaps, "find_undeclared_files", wraps=gaps.find_undeclared_files
|
||||
) as counted, mock.patch.object(packs_coverage, "find_undeclared_files", counted):
|
||||
gaps, "scan_core_files", wraps=gaps.scan_core_files
|
||||
) as counted, mock.patch.object(packs_coverage, "scan_core_files", counted):
|
||||
coverage.verify_platform(config, db, "emulators", profiles)
|
||||
finally:
|
||||
os.chdir(previous)
|
||||
|
||||
@@ -459,8 +459,8 @@ class LauncherLayerTest(unittest.TestCase):
|
||||
from packs import extras as packextras
|
||||
from packs import gaps as packs_gaps
|
||||
|
||||
self.assertIn("LauncherLayer(", inspect.getsource(packs_gaps.find_undeclared_files))
|
||||
self.assertIn(".settle(", inspect.getsource(packs_gaps.find_undeclared_files))
|
||||
self.assertIn("LauncherLayer(", inspect.getsource(packs_gaps.scan_core_files))
|
||||
self.assertIn(".settle(", inspect.getsource(packs_gaps.scan_core_files))
|
||||
self.assertIn(
|
||||
"undeclared_report(", inspect.getsource(packextras.collect_emulator_extras)
|
||||
)
|
||||
|
||||
@@ -36,5 +36,31 @@ class StandaloneFallsBackOnPath(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
class UnsourceableFilesCountedLikeGaps(unittest.TestCase):
|
||||
"""The site counted a platform's unsourceable core files by distinct
|
||||
name over every profile: gamecontrollerdb.txt read at four paths by four
|
||||
cores was one, and hatari's standalone keymap counted where hatari runs
|
||||
as a core only."""
|
||||
|
||||
def test_one_per_slot_in_the_build_the_platform_runs(self):
|
||||
from packs.gaps import scan_core_files
|
||||
|
||||
reason = {"unsourceable": "written by the user"}
|
||||
profiles = {
|
||||
"a": {"emulator": "A", "type": "libretro", "systems": ["s"], "files": [
|
||||
{"name": "db.txt", "path": "a/db.txt", **reason},
|
||||
{"name": "keymap", "path": "keymap", "mode": "standalone", **reason},
|
||||
{"name": "<font>.ttf", "path": "<font>.ttf", **reason},
|
||||
]},
|
||||
"b": {"emulator": "B", "type": "libretro", "systems": ["s"], "files": [
|
||||
{"name": "db.txt", "path": "b/db.txt", **reason},
|
||||
]},
|
||||
}
|
||||
config = {"cores": ["a", "b"], "systems": {}}
|
||||
db = {"files": {}, "indexes": {}}
|
||||
found = scan_core_files(config, "emulators", db, emu_profiles=profiles).unsourceable
|
||||
self.assertEqual(sorted(r["path"] for r in found), ["a/db.txt", "b/db.txt"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user