mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-17 17:03:27 -05:00
fix: judge packs against the run's directories
This commit is contained in:
1 parent
2714368456
commit
b4cca4a6b2
2 files changed
+95
No files matched your search
@@ -2541,6 +2541,8 @@ def _run_platform_packs(
|
||||
all_ok = verify_and_finalize_packs(
|
||||
args.output_dir,
|
||||
db,
|
||||
platforms_dir=args.platforms_dir,
|
||||
emulators_dir=args.emulators_dir,
|
||||
skip_conformance=skip_conf,
|
||||
data_registry=data_registry,
|
||||
regions=getattr(args, "regions", None),
|
||||
@@ -2553,6 +2555,8 @@ def _run_platform_packs(
|
||||
ok = verify_and_finalize_packs(
|
||||
sub,
|
||||
db,
|
||||
platforms_dir=args.platforms_dir,
|
||||
emulators_dir=args.emulators_dir,
|
||||
skip_conformance=True,
|
||||
data_registry=data_registry,
|
||||
regions=getattr(args, "regions", None),
|
||||
@@ -3940,6 +3944,7 @@ def verify_and_finalize_packs(
|
||||
data_registry: dict | None = None,
|
||||
regions: list[str] | None = None,
|
||||
target_name: str | None = None,
|
||||
emulators_dir: str = "emulators",
|
||||
) -> bool:
|
||||
"""Verify all packs, inject manifests, generate SHA256SUMS.
|
||||
|
||||
@@ -4003,6 +4008,7 @@ def verify_and_finalize_packs(
|
||||
pname,
|
||||
platforms_dir,
|
||||
db=db,
|
||||
emulators_dir=emulators_dir,
|
||||
regions=regions,
|
||||
data_registry=data_registry,
|
||||
target_cores=_target_cores_for(pname, target_name, platforms_dir),
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
"""The conformance stage reads the directories the run was given.
|
||||
|
||||
``_run_platform_packs`` called ``verify_and_finalize_packs`` without them, so
|
||||
packs built from ``--platforms-dir`` and ``--emulators-dir`` were judged
|
||||
against ``platforms/`` and ``emulators/``, or not matched to any platform at
|
||||
all and never judged.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
import generate_pack as gp # noqa: E402
|
||||
import packverify # noqa: E402
|
||||
|
||||
|
||||
class ConformanceUsesTheRunDirectories(unittest.TestCase):
|
||||
def setUp(self):
|
||||
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
|
||||
self.tmp = tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp")
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
|
||||
def _args(self, split: bool) -> argparse.Namespace:
|
||||
return argparse.Namespace(
|
||||
all_variants=False, source="full", required_only=False,
|
||||
platforms_dir="fixture-platforms", target=None, split=split,
|
||||
emulators_dir="fixture-emulators", regions=[],
|
||||
one_per_slot=False, offline=True, bios_dir="bios",
|
||||
output_dir=self.tmp.name, verify_packs=False,
|
||||
)
|
||||
|
||||
def test_run_passes_both_directories(self):
|
||||
for split in (False, True):
|
||||
if split:
|
||||
Path(self.tmp.name, "X_Split").mkdir(exist_ok=True)
|
||||
with self.subTest(split=split), mock.patch.object(
|
||||
gp, "verify_and_finalize_packs", return_value=True
|
||||
) as finalize:
|
||||
gp._run_platform_packs(
|
||||
self._args(split), [], {}, {}, {}, {}, {}, None
|
||||
)
|
||||
self.assertTrue(finalize.call_args_list)
|
||||
for call in finalize.call_args_list:
|
||||
self.assertEqual(call.kwargs.get("platforms_dir"), "fixture-platforms")
|
||||
self.assertEqual(call.kwargs.get("emulators_dir"), "fixture-emulators")
|
||||
|
||||
def test_finalizer_hands_the_emulators_directory_on(self):
|
||||
out = Path(self.tmp.name)
|
||||
(out / "Fix_BIOS_Pack.zip").write_bytes(b"")
|
||||
seen = {}
|
||||
|
||||
def record(*args, **kwargs):
|
||||
seen.update(kwargs)
|
||||
return True, 0, 0, [], 0, 0, 0, 0, 0
|
||||
|
||||
with mock.patch.object(gp, "list_registered_platforms", return_value=["fix"]), \
|
||||
mock.patch.object(
|
||||
gp, "_expected_pack_names",
|
||||
return_value={"fix": {"Fix_BIOS_Pack.zip"}},
|
||||
), \
|
||||
mock.patch.object(gp, "_pack_archives", return_value=["Fix_BIOS_Pack.zip"]), \
|
||||
mock.patch.object(
|
||||
gp, "verify_pack",
|
||||
return_value=(True, {"summary": {
|
||||
"verified": 0, "total_files": 0, "untracked": 0, "errors": 0,
|
||||
}, "errors": []}),
|
||||
), \
|
||||
mock.patch.object(gp, "inject_manifest"), \
|
||||
mock.patch.object(gp, "_target_cores_for", return_value=None), \
|
||||
mock.patch.object(gp, "verify_pack_against_platform", record), \
|
||||
mock.patch.object(packverify, "verify_pack_against_platform", record):
|
||||
gp.verify_and_finalize_packs(
|
||||
str(out), {"files": {}, "indexes": {}},
|
||||
platforms_dir="fixture-platforms",
|
||||
emulators_dir="fixture-emulators",
|
||||
)
|
||||
self.assertEqual(seen.get("emulators_dir"), "fixture-emulators")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user