mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
refactor: split the platform pack plan and zip
This commit is contained in:
1 parent
c8258522a4
commit
83055b87ea
15 files changed
+1033
-991
No files matched your search
+2
-1
@@ -17,7 +17,8 @@ SCRIPTS = Path(__file__).resolve().parents[1] / "scripts"
|
||||
COMMANDS = {
|
||||
"generate_pack.py": (
|
||||
"packs/archive.py", "packs/naming.py", "packs/scope.py", "packs/datatrees.py",
|
||||
"packs/platformpack.py", "packs/platformreport.py", "packs/emulatorpack.py",
|
||||
"packs/platformpack.py", "packs/packplan.py", "packs/platformzip.py", "packs/platformreport.py",
|
||||
"packs/emulatorpack.py",
|
||||
"packs/md5pack.py", "packs/targets.py",
|
||||
"packs/manifestentry.py", "packs/manifestcores.py", "packs/standalone.py",
|
||||
"packs/manifest.py", "packs/manifestbuild.py", "packs/finalize.py", "packs/outputdir.py", "packs/variants.py",
|
||||
|
||||
@@ -4321,7 +4321,7 @@ class AnAcceptedVersionIsNoCoreDiscrepancy(unittest.TestCase):
|
||||
"source_path": "NWINTER.GRP", "source_profile": "eduke32"}
|
||||
|
||||
def test_a_sibling_version_matches(self):
|
||||
from scripts.packs.platformpack import _matches_an_alternative
|
||||
from scripts.packs.platformzip import _matches_an_alternative
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
held = Path(tmp) / "NWINTER.GRP"
|
||||
@@ -4332,7 +4332,7 @@ class AnAcceptedVersionIsNoCoreDiscrepancy(unittest.TestCase):
|
||||
self._extra(), str(held), {"eduke32": profile}))
|
||||
|
||||
def test_a_copy_no_entry_declares_still_disagrees(self):
|
||||
from scripts.packs.platformpack import _matches_an_alternative
|
||||
from scripts.packs.platformzip import _matches_an_alternative
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
held = Path(tmp) / "NWINTER.GRP"
|
||||
|
||||
@@ -18,6 +18,7 @@ from pathlib import Path
|
||||
import yaml
|
||||
from packs import archive
|
||||
from packs import platformpack
|
||||
from packs import platformzip
|
||||
|
||||
from model.platforms import load_platform_config
|
||||
|
||||
@@ -85,14 +86,14 @@ class ThePackReadmeNamesTheSpellingsItLeavesOut(unittest.TestCase):
|
||||
}}}))
|
||||
_platform_config_cache.clear()
|
||||
texts: dict[str, str] = {}
|
||||
real = platformpack.write_generated_member
|
||||
real = platformzip.write_generated_member
|
||||
|
||||
def capture(zf, arcname, text):
|
||||
texts[arcname] = text
|
||||
return real(zf, arcname, text)
|
||||
|
||||
platformpack.write_generated_member = capture
|
||||
self.addCleanup(setattr, platformpack, "write_generated_member", real)
|
||||
platformzip.write_generated_member = capture
|
||||
self.addCleanup(setattr, platformzip, "write_generated_member", real)
|
||||
platformpack.build_platform_pack(
|
||||
"p", "platforms", self.db, "bios", "", emulators_dir="emulators",
|
||||
offline=True, record=archive.PackRecord(),
|
||||
|
||||
@@ -34,7 +34,7 @@ from model.registry import list_registered_platforms, load_data_dir_registry
|
||||
from resolve.localfile import resolve_local_file
|
||||
from resolve.ownership import BUCKET_FOLDERS, names_manufacturer
|
||||
from collection.indexes import shadowed_alias_index
|
||||
from packs import manifest as packs_manifest, md5pack, naming as packs_naming, platformpack
|
||||
from packs import manifest as packs_manifest, md5pack, naming as packs_naming, packplan, platformpack
|
||||
from resolve import ownership
|
||||
from packs.coverage import verify_platform
|
||||
|
||||
@@ -197,7 +197,7 @@ class DiskRomGoesToThePc88File(_Collection):
|
||||
manifest = self._manifest()
|
||||
original = (platforms.load_platform_config, localfile.system_makers)
|
||||
# Every module that reads the loader by its own name sees the stub.
|
||||
readers = (packs_manifest, md5pack, packs_naming, platformpack, platforms, cliargs, cores, grouping)
|
||||
readers = (packs_manifest, md5pack, packs_naming, packplan, platformpack, platforms, cliargs, cores, grouping)
|
||||
|
||||
def untagged(*args, **kwargs):
|
||||
config = original[0](*args, **kwargs)
|
||||
|
||||
@@ -266,8 +266,9 @@ class EveryNarrowingIsCompared(unittest.TestCase):
|
||||
|
||||
from orchestrate import narrowed
|
||||
from packs import platformpack
|
||||
from packs import platformzip
|
||||
|
||||
refused = platformpack.PlatformPackOutcome(zip_path=None, refusal="no core runs x")
|
||||
refused = platformzip.PlatformPackOutcome(zip_path=None, refusal="no core runs x")
|
||||
inputs = ({}, {}, {}, {}, [(["p"], "p")])
|
||||
printed = io.StringIO()
|
||||
with mock.patch.object(narrowed, "comparison_inputs", return_value=inputs), \
|
||||
|
||||
@@ -22,7 +22,7 @@ class SlotPassReadsTheRegionGrouping(unittest.TestCase):
|
||||
def test_ranked_mega_cd_alternatives_are_decided(self):
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
self.skipTest("database.json not built")
|
||||
from packs import platformpack
|
||||
from packs import packplan
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
from model.platforms import load_platform_config
|
||||
@@ -33,7 +33,7 @@ class SlotPassReadsTheRegionGrouping(unittest.TestCase):
|
||||
db = load_database("database.json")
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
config = load_platform_config("retroarch", "platforms")
|
||||
drops, _fallbacks, _undecided = platformpack._select_variants(
|
||||
drops, _fallbacks, _undecided = packplan._select_variants(
|
||||
config, config["systems"], "emulators", db,
|
||||
config.get("base_destination", ""), profiles, None, "full",
|
||||
regions=None, one_per_slot=True,
|
||||
@@ -57,7 +57,7 @@ class VariantGroupSpansSystems(unittest.TestCase):
|
||||
"""
|
||||
if not (REPO_ROOT / "database.json").is_file():
|
||||
self.skipTest("database.json not built")
|
||||
from packs import platformpack
|
||||
from packs import packplan
|
||||
from model import region
|
||||
from model.database import load_database
|
||||
from model.profiles import load_emulator_profiles
|
||||
@@ -69,7 +69,7 @@ class VariantGroupSpansSystems(unittest.TestCase):
|
||||
db = load_database("database.json")
|
||||
profiles = load_emulator_profiles("emulators")
|
||||
config = load_platform_config("retroarch", "platforms")
|
||||
drops, _fallbacks, _undecided = platformpack._select_variants(
|
||||
drops, _fallbacks, _undecided = packplan._select_variants(
|
||||
config, config["systems"], "emulators", db,
|
||||
config.get("base_destination", ""), profiles, None, "full",
|
||||
regions=region.parse_requested("us"), one_per_slot=False,
|
||||
|
||||
+4
-4
@@ -271,7 +271,7 @@ class TestConflicts(unittest.TestCase):
|
||||
"""
|
||||
import inspect
|
||||
|
||||
from packs import coverage, manifest, platformpack
|
||||
from packs import coverage, manifest, packplan
|
||||
|
||||
for function in (
|
||||
packs_slots.platform_claims,
|
||||
@@ -292,7 +292,7 @@ class TestConflicts(unittest.TestCase):
|
||||
# the ZIP builder, the install manifest and the report. The manifest
|
||||
# deciding nothing gave the installer other bytes than the ZIP.
|
||||
for tool, modules, calls in (
|
||||
("generate_pack", (platformpack, manifest), 2), ("verify", (coverage,), 1),
|
||||
("generate_pack", (packplan, manifest), 2), ("verify", (coverage,), 1),
|
||||
):
|
||||
source = "".join(inspect.getsource(module) for module in modules)
|
||||
with self.subTest(tool=tool):
|
||||
@@ -528,7 +528,7 @@ class TestBuilderAndVerifierAgree(unittest.TestCase):
|
||||
# The rule lives in one place. A second copy would let the pack and the
|
||||
# report describe different files, which the project forbids outright.
|
||||
scripts = Path(__file__).resolve().parents[1] / "scripts"
|
||||
builder = (scripts / "packs" / "platformpack.py", scripts / "packs" / "manifest.py")
|
||||
builder = (scripts / "packs" / "packplan.py", scripts / "packs" / "manifest.py")
|
||||
verifier = (scripts / "packs" / "coverage.py",)
|
||||
for source in (*builder, *verifier):
|
||||
text = source.read_text(encoding="utf-8")
|
||||
@@ -545,7 +545,7 @@ class TestBuilderAndVerifierAgree(unittest.TestCase):
|
||||
# override lookup both sides must perform. The old anchor was a string
|
||||
# the test above forbids, so the window was the whole file.
|
||||
mode_test = re.compile(r"""[=!]=\s*["'](?:md5|sha1|existence)["']""")
|
||||
for name in ("packs/platformpack.py", "packs/manifestbuild.py", "packs/platformtally.py"):
|
||||
for name in ("packs/platformzip.py", "packs/manifestbuild.py", "packs/platformtally.py"):
|
||||
source = Path(__file__).resolve().parents[1] / "scripts" / name
|
||||
body = source.read_text(encoding="utf-8")
|
||||
anchors = [m.start() for m in re.finditer(r"slot_overrides\.get\(", body)]
|
||||
|
||||
@@ -150,7 +150,7 @@ class ASplitBuildsOnlyTheTargetsSystems(unittest.TestCase):
|
||||
def test_no_part_is_asked_for_a_dropped_system(self):
|
||||
from unittest import mock
|
||||
|
||||
from packs import manifestbuild, platformpack
|
||||
from packs import manifestbuild, platformpack, platformzip
|
||||
from packs import platformpack as packs_platformpack
|
||||
from model.profiles import load_emulator_profiles
|
||||
|
||||
@@ -161,12 +161,13 @@ class ASplitBuildsOnlyTheTargetsSystems(unittest.TestCase):
|
||||
def record(*_a, **kw):
|
||||
if kw.get("system_filter"):
|
||||
asked.append(kw["system_filter"])
|
||||
return platformpack.PlatformPackOutcome(zip_path=None)
|
||||
return platformzip.PlatformPackOutcome(zip_path=None)
|
||||
|
||||
with tempfile.TemporaryDirectory() as out, \
|
||||
mock.patch.object(platformpack, "build_platform_pack", record), \
|
||||
mock.patch.object(platformpack, "print_split_packs"), \
|
||||
mock.patch.object(platformpack, "collect_emulator_extras", return_value=[]), \
|
||||
mock.patch.object(platformzip, "collect_emulator_extras", return_value=[]), \
|
||||
mock.patch.object(manifestbuild, "collect_emulator_extras", return_value=[]):
|
||||
packs_platformpack.generate_split_packs(
|
||||
"retroarch", platforms, {"files": {}}, "bios", out,
|
||||
@@ -316,16 +317,18 @@ class TheSplitDirectoryReadsThePackStem(unittest.TestCase):
|
||||
def test_a_reserved_character_is_made_safe_as_in_the_full_pack(self):
|
||||
from unittest import mock
|
||||
|
||||
from packs import manifest, manifestbuild, md5pack, naming
|
||||
from packs import manifest, manifestbuild, md5pack, naming, packplan, platformzip
|
||||
from packs import platformpack as packs_platformpack
|
||||
|
||||
config = {"platform": "Foo: Bar", "version": "release/1.22", "systems": {}}
|
||||
with tempfile.TemporaryDirectory() as out, \
|
||||
mock.patch.object(packs_platformpack, "load_platform_config", return_value=config), \
|
||||
mock.patch.object(packplan, "load_platform_config", return_value=config), \
|
||||
mock.patch.object(naming, "load_platform_config", return_value=config), \
|
||||
mock.patch.object(manifest, "load_platform_config", return_value=config), \
|
||||
mock.patch.object(md5pack, "load_platform_config", return_value=config), \
|
||||
mock.patch.object(packs_platformpack, "collect_emulator_extras", return_value=[]), \
|
||||
mock.patch.object(platformzip, "collect_emulator_extras", return_value=[]), \
|
||||
mock.patch.object(manifestbuild, "collect_emulator_extras", return_value=[]):
|
||||
packs_platformpack.generate_split_packs(
|
||||
"foo", "platforms", {"files": {}}, "bios", out, emu_profiles={},
|
||||
|
||||
@@ -360,11 +360,11 @@ class AVersionTakenWithoutACheck(unittest.TestCase):
|
||||
))
|
||||
|
||||
def test_the_pack_reads_it_as_an_alternative(self):
|
||||
from packs import platformpack
|
||||
from packs import platformzip
|
||||
|
||||
fe = {"name": "BLOOD.RFF", "source_profile": "raze", "source_path": "BLOOD.RFF"}
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
self.assertTrue(platformpack._matches_an_alternative(
|
||||
self.assertTrue(platformzip._matches_an_alternative(
|
||||
fe, self._file(tmp), {"raze": self.RAZE}
|
||||
))
|
||||
|
||||
|
||||
Reference in new issue
Block a user