mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 09:23:26 -05:00
fix: read core files in verify as the builder does
This commit is contained in:
1 parent
3766588ec1
commit
fad4fa6d7e
8 files changed
+51
-31
No files matched your search
@@ -45,7 +45,6 @@ def compute_coverage(
|
||||
platforms_dir: str,
|
||||
db: dict,
|
||||
data_registry: dict | None = None,
|
||||
supplemental_names: set[str] | None = None,
|
||||
emulators_dir: str = _EMULATORS_DIR,
|
||||
) -> dict:
|
||||
config = load_platform_config(platform_name, platforms_dir)
|
||||
@@ -54,7 +53,6 @@ def compute_coverage(
|
||||
db,
|
||||
emulators_dir,
|
||||
data_dir_registry=data_registry,
|
||||
supplemental_names=supplemental_names,
|
||||
)
|
||||
sc = result.get("status_counts", {})
|
||||
ok = sc.get("ok", 0)
|
||||
@@ -295,16 +293,14 @@ def generate_readme(db: dict, platforms_dir: str) -> str:
|
||||
platform_names = list_registered_platforms(platforms_dir, include_archived=True)
|
||||
|
||||
from common import load_data_dir_registry
|
||||
from cross_reference import _build_supplemental_index
|
||||
|
||||
data_registry = load_data_dir_registry(platforms_dir)
|
||||
suppl_names = _build_supplemental_index()
|
||||
|
||||
coverages = {}
|
||||
for name in platform_names:
|
||||
try:
|
||||
coverages[name] = compute_coverage(
|
||||
name, platforms_dir, db, data_registry, suppl_names
|
||||
name, platforms_dir, db, data_registry
|
||||
)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
@@ -3813,7 +3813,7 @@ def main() -> None:
|
||||
for name in sorted(platform_names):
|
||||
try:
|
||||
cov = compute_coverage(
|
||||
name, args.platforms_dir, db, data_registry, suppl_names,
|
||||
name, args.platforms_dir, db, data_registry,
|
||||
emulators_dir=args.emulators_dir,
|
||||
)
|
||||
coverages[name] = cov
|
||||
|
||||
+6
-15
@@ -884,7 +884,6 @@ def verify_platform(
|
||||
emu_profiles: dict | None = None,
|
||||
target_cores: set[str] | None = None,
|
||||
data_dir_registry: dict | None = None,
|
||||
supplemental_names: set[str] | None = None,
|
||||
regions: list[str] | None = None,
|
||||
) -> dict:
|
||||
"""Verify all BIOS files for a platform, including cross-reference gaps.
|
||||
@@ -1085,22 +1084,18 @@ def verify_platform(
|
||||
):
|
||||
file_severity[dest] = sev
|
||||
|
||||
# Cross-reference undeclared files
|
||||
if supplemental_names is None:
|
||||
from cross_reference import _build_supplemental_index
|
||||
|
||||
supplemental_names = _build_supplemental_index()
|
||||
# The builder's declarations, not the enriched ones: a core file the
|
||||
# platform also declares under another name is packed at the core's own
|
||||
# path, and a report reading the enriched set never counted it (21 such
|
||||
# files in the RetroArch pack).
|
||||
# Cross-reference undeclared files, called exactly as the builder calls
|
||||
# it: its declarations, not the enriched ones (a core file the platform
|
||||
# also declares under another name is packed at the core's own path, 21
|
||||
# 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(
|
||||
config,
|
||||
emulators_dir,
|
||||
db,
|
||||
emu_profiles,
|
||||
target_cores=target_cores,
|
||||
data_names=supplemental_names,
|
||||
declared_names=platform_declarations(config, db, enrich=False),
|
||||
)
|
||||
if region_drops:
|
||||
@@ -2226,9 +2221,6 @@ def _main(held: contextlib.ExitStack) -> None:
|
||||
groups = group_identical_platforms(
|
||||
platforms, args.platforms_dir, target_cores_cache if args.target else None
|
||||
)
|
||||
from cross_reference import _build_supplemental_index
|
||||
|
||||
suppl_names = _build_supplemental_index()
|
||||
|
||||
all_results = {}
|
||||
group_results: list[tuple[dict, list[str]]] = []
|
||||
@@ -2242,7 +2234,6 @@ def _main(held: contextlib.ExitStack) -> None:
|
||||
emu_profiles,
|
||||
target_cores=tc,
|
||||
data_dir_registry=data_registry,
|
||||
supplemental_names=suppl_names,
|
||||
regions=requested_regions,
|
||||
)
|
||||
names = [
|
||||
|
||||
@@ -79,7 +79,7 @@ class ACoreFileFillsAFreeDeclaration(unittest.TestCase):
|
||||
|
||||
def test_verify_counts_what_the_pack_counts(self):
|
||||
result = verify_platform(
|
||||
self.config, self.db, str(self.emulators), supplemental_names=set(),
|
||||
self.config, self.db, str(self.emulators),
|
||||
)
|
||||
out = self.root / "out"
|
||||
with redirect_stdout(io.StringIO()):
|
||||
@@ -131,7 +131,7 @@ class AFileDeclaredUnderAnotherName(unittest.TestCase):
|
||||
"files": [{"name": "ROM", "path": "gs/ROM", "md5": md5, "required": True}],
|
||||
}))
|
||||
config = load_platform_config("fakeplat", str(root / "platforms"))
|
||||
result = verify_platform(config, db, str(root / "emulators"), supplemental_names=set())
|
||||
result = verify_platform(config, db, str(root / "emulators"))
|
||||
with redirect_stdout(io.StringIO()):
|
||||
zip_path = generate_pack(
|
||||
"fakeplat", str(root / "platforms"), db, str(root / "bios"),
|
||||
@@ -223,5 +223,41 @@ class AFileNobodyHoldsIsAnOmission(unittest.TestCase):
|
||||
self.assertEqual(omitted["diabdat.mpq"]["reason"], "not_found")
|
||||
|
||||
|
||||
|
||||
class AMemberNameIsNotALooseFile(unittest.TestCase):
|
||||
"""verify counted a core file "in pack" when its name existed only as a
|
||||
member of some ZIP (naomi2.zip's 315-6146.bin); the builder, which reads
|
||||
no archive member names, shipped nothing."""
|
||||
|
||||
def test_verify_reads_undeclared_files_as_the_builder_does(self):
|
||||
import cross_reference
|
||||
|
||||
_emulator_profiles_cache.clear()
|
||||
root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.addCleanup(shutil.rmtree, root, True)
|
||||
(root / "platforms").mkdir()
|
||||
(root / "emulators").mkdir()
|
||||
(root / "platforms" / "fakeplat.yml").write_text(yaml.safe_dump({
|
||||
"platform": "FakePlat", "verification_mode": "existence",
|
||||
"base_destination": "system", "cores": ["naomi2core"],
|
||||
"systems": {"sega-naomi2": {"files": []}},
|
||||
}))
|
||||
(root / "emulators" / "naomi2core.yml").write_text(yaml.safe_dump({
|
||||
"emulator": "N2", "type": "libretro", "cores": ["naomi2core"],
|
||||
"systems": ["sega-naomi2"],
|
||||
"files": [{"name": "315-6146.bin", "required": True}],
|
||||
}))
|
||||
db = {"files": {}, "indexes": {"by_md5": {}, "by_name": {}, "by_crc32": {},
|
||||
"by_path_suffix": {}}}
|
||||
config = load_platform_config("fakeplat", str(root / "platforms"))
|
||||
with mock.patch.object(cross_reference, "_build_supplemental_index",
|
||||
lambda *a, **k: {"315-6146.bin"}):
|
||||
result = verify_platform(config, db, str(root / "emulators"))
|
||||
self.assertEqual(
|
||||
[(u["name"], u["in_repo"]) for u in result["undeclared_files"]],
|
||||
[("315-6146.bin", False)],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -157,7 +157,6 @@ class ThePolicyIsSpeltInOnePlace(unittest.TestCase):
|
||||
}
|
||||
result = verify.verify_platform(
|
||||
config, {"files": {}, "indexes": {}}, emu_profiles={},
|
||||
supplemental_names=set(),
|
||||
)
|
||||
self.assertEqual(result["verification_mode"], nativemode.DEFAULT_MODE)
|
||||
|
||||
|
||||
@@ -659,11 +659,10 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
|
||||
plain = reporter.verify_platform(
|
||||
config, db, str(root / "emulators"), profiles,
|
||||
supplemental_names=set(),
|
||||
)
|
||||
narrowed = reporter.verify_platform(
|
||||
config, db, str(root / "emulators"), profiles,
|
||||
supplemental_names=set(), regions=["north-america"],
|
||||
regions=["north-america"],
|
||||
)
|
||||
before = {u["name"] for u in plain["undeclared_files"]}
|
||||
after = {u["name"] for u in narrowed["undeclared_files"]}
|
||||
@@ -694,11 +693,10 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
profiles = common.load_emulator_profiles(str(root / "emulators"))
|
||||
plain = reporter.verify_platform(
|
||||
config, db, str(root / "emulators"), profiles,
|
||||
supplemental_names=set(),
|
||||
)
|
||||
narrowed = reporter.verify_platform(
|
||||
config, db, str(root / "emulators"), profiles,
|
||||
supplemental_names=set(), regions=["north-america"],
|
||||
regions=["north-america"],
|
||||
)
|
||||
missing = [u["name"] for u in plain["undeclared_files"] if not u["in_repo"]]
|
||||
self.assertEqual(missing, ["jp.bin"])
|
||||
@@ -722,7 +720,7 @@ class TestReportAndBuilderNarrowTogether(unittest.TestCase):
|
||||
profiles = common.load_emulator_profiles(str(root / "emulators"))
|
||||
result = reporter.verify_platform(
|
||||
config, db, str(root / "emulators"), profiles,
|
||||
supplemental_names=set(), regions=["brazil"],
|
||||
regions=["brazil"],
|
||||
)
|
||||
self.assertEqual(result["region_fallbacks"], ["demo-system"])
|
||||
out = io.StringIO()
|
||||
|
||||
@@ -68,7 +68,7 @@ class TwinDeclarations(unittest.TestCase):
|
||||
},
|
||||
}
|
||||
report = verify_platform(
|
||||
config, self.db, str(self.emulators), {}, supplemental_names=set()
|
||||
config, self.db, str(self.emulators), {}
|
||||
)
|
||||
by_system = {d["system"]: d for d in report["details"] if d["name"] in ("N88SUB.ROM", "disk.rom")}
|
||||
statuses = sorted(d["status"] for d in by_system.values())
|
||||
|
||||
@@ -86,7 +86,7 @@ class SlugPlatform(unittest.TestCase):
|
||||
|
||||
def test_the_report_does_not_count_it_packed(self):
|
||||
report = verify_platform(
|
||||
self.config, self.db, "emulators", self.profiles, supplemental_names=set()
|
||||
self.config, self.db, "emulators", self.profiles
|
||||
)
|
||||
entry = next(u for u in report["undeclared_files"] if u["name"] == "MT32_CONTROL.ROM")
|
||||
self.assertTrue(entry["in_repo"])
|
||||
|
||||
Reference in new issue
Block a user