refactor: carry platform launches as a dataclass

standalone_set returned one string set mixing standalone names with ten
JSON-tagged record kinds that every reader re-decoded. platform_launches
now returns a frozen PlatformLaunches (resolve/launches.py) with typed
fields, runs_standalone, is_dual, system_file_index and merged, which
_build_layouts and packprobe share.
This commit is contained in:
Abdessamad Derraz committed 2026-11-24 02:18:53 +01:00
1 parent d3b741e423
commit 6e44a93156
34 files changed
+493 -467

No files matched your search

+5 -5
View File
@@ -4544,7 +4544,7 @@ class OpenMsxRomsSitInItsSystemroms(unittest.TestCase):
def test_every_entry_is_under_share_systemroms(self):
from scripts.model.profiles import load_emulator_profiles
from scripts.model.platforms import load_platform_config
from scripts.resolve.standalone import platform_layouts, standalone_set
from scripts.resolve.standalone import platform_layouts, platform_launches
profiles = load_emulator_profiles(str(ROOT / "emulators"))
profile = profiles["openmsx"]
@@ -4557,7 +4557,7 @@ class OpenMsxRomsSitInItsSystemroms(unittest.TestCase):
}
self.assertEqual(declared_dirs, {"openmsx/share/systemroms"})
config = load_platform_config("retrobat", str(ROOT / "platforms"))
((view, _standalone),) = platform_layouts("openmsx", profile, standalone_set(config, profiles))
((view, _standalone),) = platform_layouts("openmsx", profile, platform_launches(config, profiles))
placed = {f["name"]: f for f in view["files"]}
for entry in profile["files"]:
with self.subTest(name=entry["name"]):
@@ -5385,7 +5385,7 @@ class EmuDeckRunsItsEmulatorsStandalone(unittest.TestCase):
def test_every_emuscripts_emulator_is_standalone(self):
from scripts.model.platforms import load_platform_config
from scripts.resolve.layout import runs_standalone
from scripts.resolve.launches import PlatformLaunches
from scripts.model.profiles import load_emulator_profiles
config = load_platform_config("emudeck", str(ROOT / "platforms"))
@@ -5394,10 +5394,10 @@ class EmuDeckRunsItsEmulatorsStandalone(unittest.TestCase):
sorted(c for c in config["cores"] if c != "retroarch"),
)
profiles = load_emulator_profiles(str(ROOT / "emulators"))
standalone = set(config["standalone_cores"])
standalone = PlatformLaunches(standalone=frozenset(config["standalone_cores"]))
for name in ("dolphin", "cemu", "armsx2", "supermodel"):
with self.subTest(emulator=name):
self.assertTrue(runs_standalone(name, profiles[name], standalone))
self.assertTrue(standalone.runs_standalone(name, profiles[name]))
def test_retroarch_brings_its_libretro_cores(self):
"""The scraper dropped RetroArch's own script: np2kai, neocd and
+6 -3
View File
@@ -112,13 +112,16 @@ class AnEmulatorLaunchedBothWaysGetsBothLayouts(unittest.TestCase):
self.assertEqual(standalone & es_systems_libretro(text), {"dolphin"})
def test_the_layouts_are_both(self):
from resolve.layout import DUAL_MODE_PREFIX
from resolve.launches import PlatformLaunches
from resolve.standalone import platform_layouts
profile = {"type": "standalone + libretro", "cores": ["dolphin"], "files": []}
both = platform_layouts("dolphin", profile, {"dolphin", DUAL_MODE_PREFIX + "dolphin"})
dolphin = frozenset({"dolphin"})
both = platform_layouts(
"dolphin", profile, PlatformLaunches(standalone=dolphin, dual=dolphin)
)
self.assertEqual([standalone for _view, standalone in both], [False, True])
only = platform_layouts("dolphin", profile, {"dolphin"})
only = platform_layouts("dolphin", profile, PlatformLaunches(standalone=dolphin))
self.assertEqual([standalone for _view, standalone in only], [True])
def test_the_batocera_manifest_carries_both(self):
+2 -2
View File
@@ -22,7 +22,7 @@ from model.platforms import load_platform_config
from model.profiles import load_emulator_profiles, installed_data_refs_in
from model.registry import load_data_dir_registry, list_registered_platforms
from resolve.cores import resolve_platform_cores
from resolve.standalone import platform_layouts, standalone_set
from resolve.standalone import platform_layouts, platform_launches
from packs import archive
from packs import datatrees
from packs import platformpack
@@ -155,7 +155,7 @@ class EveryReaderHasTheTreeOrAReason(unittest.TestCase):
unexplained = []
for platform in list_registered_platforms(platforms_dir):
config = load_platform_config(platform, platforms_dir)
handed = standalone_set(config, profiles)
handed = platform_launches(config, profiles)
for core in sorted(resolve_platform_cores(config, profiles)):
profile = profiles[core]
if all(standalone for _view, standalone
+10 -8
View File
@@ -6872,18 +6872,20 @@ class StandaloneModeRequiresAStandaloneBuild(unittest.TestCase):
profile loses every ``path:`` and drops its files at the root."""
def test_libretro_only_profile_keeps_its_layout(self):
from resolve.layout import runs_standalone
from resolve.launches import PlatformLaunches
libretro_only = {"type": "libretro", "cores": ["scummvm"]}
dual = {"type": "standalone + libretro", "cores": ["dolphin"]}
standalone = {"type": "standalone", "cores": ["xemu"]}
named = {"scummvm", "dolphin", "xemu", "hatari"}
self.assertFalse(runs_standalone("scummvm", libretro_only, named))
self.assertTrue(runs_standalone("dolphin", dual, named))
self.assertTrue(runs_standalone("xemu", standalone, named))
self.assertTrue(runs_standalone("other-key", {"type": "standalone", "cores": ["hatari"]}, named))
self.assertFalse(runs_standalone("dolphin", dual, set()))
self.assertFalse(runs_standalone("dolphin", dual, {"pcsx2"}))
named = PlatformLaunches(standalone=frozenset({"scummvm", "dolphin", "xemu", "hatari"}))
self.assertFalse(named.runs_standalone("scummvm", libretro_only))
self.assertTrue(named.runs_standalone("dolphin", dual))
self.assertTrue(named.runs_standalone("xemu", standalone))
self.assertTrue(named.runs_standalone("other-key", {"type": "standalone", "cores": ["hatari"]}))
self.assertFalse(PlatformLaunches().runs_standalone("dolphin", dual))
self.assertFalse(
PlatformLaunches(standalone=frozenset({"pcsx2"})).runs_standalone("dolphin", dual)
)
+2 -1
View File
@@ -14,6 +14,7 @@ import unittest
from pathlib import Path
from packs.crossref import cross_reference
from resolve.launches import PlatformLaunches
from resolve.validation import case_folded_slots, declaration_settles
REPO_ROOT = Path(__file__).resolve().parents[1]
@@ -87,7 +88,7 @@ class TheRunningBuildPlacesTheGap(unittest.TestCase):
"systems": ["nintendo-wiiu"], "files": [self.KEYS]}}
report = cross_reference(
profiles, {}, {"files": {}, "indexes": {}}, all_declared={},
standalone_cores=standalone,
standalone_cores=PlatformLaunches(standalone=frozenset(standalone)),
)
return [g["path"] for g in report["cemu"]["gap_details"]]
+7 -11
View File
@@ -18,8 +18,7 @@ import yaml
from model.platforms import load_platform_config
from model.profiles import load_emulator_profiles
from resolve.categories import EntryCategories
from resolve.layout import EXECUTED_PREFIX, HANDED_PREFIX
from resolve.standalone import standalone_set
from resolve.standalone import platform_launches
from resolve.launchers import (
bound_launchers,
config_evidence,
@@ -209,26 +208,23 @@ class Gate(unittest.TestCase):
self.assertEqual(len(bound_launchers(config, {"duck": profile(config_reads=[])})), 1)
def test_the_layout_is_proven_against_the_profiles_given(self) -> None:
"""The pack's tag set and cross_reference judge with the same profiles:
"""The pack's launches and cross_reference judge with the same profiles:
an --emulators-dir whose profile lacks config_reads hands nothing."""
config = {**self.config(record()), "standalone_cores": ["duck"]}
handed = [t for t in standalone_set(config, {"duck": profile()}) if t.startswith(HANDED_PREFIX)]
self.assertEqual(len(handed), 1)
self.assertFalse([t for t in standalone_set(config, {"duck": profile(config_reads=[])})
if t.startswith(HANDED_PREFIX)])
self.assertEqual(len(platform_launches(config, {"duck": profile()}).handed), 1)
self.assertFalse(platform_launches(config, {"duck": profile(config_reads=[])}).handed)
def test_an_unproven_record_executes_nothing(self) -> None:
code = {"emulator": "duck", "kind": "fixed_name", "names": ["run.sh"], "passes_to": "exec",
"search_dir": "/storage/roms/bios", "source_ref": "start.sh:3"}
cited = {**code, "source_ref": "duck/config/settings.ini:4, start.sh:3"}
def executed(launcher: dict) -> list[str]:
def executed(launcher: dict) -> tuple:
config = {**self.config(launcher), "standalone_cores": ["duck"]}
return [t for t in standalone_set(config, {"duck": profile()})
if t.startswith(EXECUTED_PREFIX)]
return platform_launches(config, {"duck": profile()}).executed
self.assertEqual(len(executed(code)), 1)
self.assertEqual(executed(cited), [])
self.assertEqual(executed(cited), ())
def test_an_unproven_record_proves_no_read(self) -> None:
named = record(kind="fixed_name", names=["tos.img"], passes_to="settings.ini [BIOS] PathPAL")
+2 -1
View File
@@ -23,6 +23,7 @@ import yaml
from model.profiles import emulator_profiles_cache, load_emulator_profiles
from model.platforms import load_platform_config
from resolve.launches import PlatformLaunches
from resolve.launchers import LauncherLayer, launcher_places, suffixed_stem
from packs.gaps import find_undeclared_files
from packs.coverage import verify_platform
@@ -443,7 +444,7 @@ class LauncherLayerTest(unittest.TestCase):
report = cross_reference(
self.profiles, declared, self.db, set(),
all_declared=scope["all_declared"],
standalone_cores={"psxemu", "fixemu"},
standalone_cores=PlatformLaunches(standalone=frozenset({"psxemu", "fixemu"})),
platform="launchertest", launcher_layer=layer,
)
gaps = sorted(
+2 -2
View File
@@ -349,7 +349,7 @@ class AUserFolderInTheConfigsFolder(unittest.TestCase):
from model.profiles import load_emulator_profiles
from model.platforms import load_platform_config
from resolve.standalone import platform_layouts
from resolve.standalone import standalone_set
from resolve.standalone import platform_launches
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
profile = profiles["shadps4"]
@@ -357,7 +357,7 @@ class AUserFolderInTheConfigsFolder(unittest.TestCase):
for platform in ("batocera",):
config = load_platform_config(platform, str(REPO_ROOT / "platforms"))
((view, _standalone),) = platform_layouts(
"shadps4", profile, standalone_set(config, profiles)
"shadps4", profile, platform_launches(config, profiles)
)
with self.subTest(platform=platform):
self.assertEqual(
+14 -18
View File
@@ -13,7 +13,6 @@ import tests
import hashlib
import io
import json
import shutil
import tempfile
import unittest
@@ -25,7 +24,7 @@ import yaml
from model.profiles import emulator_profiles_cache, load_emulator_profiles
from model.platforms import load_platform_config
from resolve.standalone import platform_layouts, standalone_set
from resolve.standalone import platform_layouts, platform_launches
from packs.manifest import generate_manifest
from packs.platformpack import build_platform_pack
from packs.coverage import verify_platform
@@ -204,7 +203,7 @@ class ALinkMovesTheDestination(unittest.TestCase):
config = {"standalone_cores": ["kick"], "launchers": [LINK]}
profiles = load_emulator_profiles(str(self.emulators))
profile = profiles["kick"]
(view, standalone), = platform_layouts("kick", profile, standalone_set(config, profiles))
(view, standalone), = platform_layouts("kick", profile, platform_launches(config, profiles))
self.assertTrue(standalone)
self.assertNotIn("standalone_path", view["files"][0])
@@ -216,7 +215,7 @@ class UAE4AllOnRetroPie(unittest.TestCase):
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
profile = profiles["uae4all"]
config = load_platform_config("retropie", str(REPO_ROOT / "platforms"))
(view, standalone), = platform_layouts("uae4all", profile, standalone_set(config, profiles))
(view, standalone), = platform_layouts("uae4all", profile, platform_launches(config, profiles))
self.assertTrue(standalone)
for entry in view["files"]:
if entry["path"].startswith("kickstarts/"):
@@ -689,7 +688,7 @@ class AetherSX2OnKnulli(unittest.TestCase):
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
profile = profiles["aethersx2"]
config = load_platform_config("knulli", str(REPO_ROOT / "platforms"))
(view, standalone), = platform_layouts("aethersx2", profile, standalone_set(config, profiles))
(view, standalone), = platform_layouts("aethersx2", profile, platform_launches(config, profiles))
self.assertTrue(standalone)
for entry in view["files"]:
path = entry.get("path") or ""
@@ -706,7 +705,7 @@ class Quasi88OnRetroPie(unittest.TestCase):
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
profile = profiles["quasi88kai"]
config = load_platform_config("retropie", str(REPO_ROOT / "platforms"))
(view, standalone), = platform_layouts("quasi88kai", profile, standalone_set(config, profiles))
(view, standalone), = platform_layouts("quasi88kai", profile, platform_launches(config, profiles))
self.assertTrue(standalone)
paths = [e["path"] for e in view["files"]]
self.assertTrue(paths and all(p.startswith("rom/") for p in paths))
@@ -736,7 +735,7 @@ class FlycastOnEmuELEC(unittest.TestCase):
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
profile = profiles["flycast"]
config = load_platform_config("emuelec", str(REPO_ROOT / "platforms"))
layouts = platform_layouts("flycast", profile, standalone_set(config, profiles))
layouts = platform_layouts("flycast", profile, platform_launches(config, profiles))
(view,) = [v for v, standalone in layouts if standalone]
self.assertTrue(view["files"])
for entry in view["files"]:
@@ -747,7 +746,7 @@ def standalone_view(emulator: str, platform: str) -> dict:
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
profile = profiles[emulator]
config = load_platform_config(platform, str(REPO_ROOT / "platforms"))
(view,) = [v for v, standalone in platform_layouts(emulator, profile, standalone_set(config, profiles))
(view,) = [v for v, standalone in platform_layouts(emulator, profile, platform_launches(config, profiles))
if standalone]
return view
@@ -939,7 +938,7 @@ class LibretroMameSetsInMameBios(unittest.TestCase):
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
profile = profiles["mame"]
config = load_platform_config("retrobat", str(REPO_ROOT / "platforms"))
builds = sorted(s for _v, s in platform_layouts("mame", profile, standalone_set(config, profiles)))
builds = sorted(s for _v, s in platform_layouts("mame", profile, platform_launches(config, profiles)))
self.assertEqual(builds, [False, True])
@@ -1041,7 +1040,7 @@ def libretro_view(emulator: str, platform: str) -> dict:
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
profile = profiles[emulator]
config = load_platform_config(platform, str(REPO_ROOT / "platforms"))
(view,) = [v for v, standalone in platform_layouts(emulator, profile, standalone_set(config, profiles))
(view,) = [v for v, standalone in platform_layouts(emulator, profile, platform_launches(config, profiles))
if not standalone]
return view
@@ -1232,12 +1231,12 @@ class AdvanceMameOnRetroPie(unittest.TestCase):
def test_the_sets_go_to_the_first_folder_searched(self) -> None:
config = load_platform_config("retropie", str(REPO_ROOT / "platforms"))
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
tags = standalone_set(config, profiles)
launches = platform_launches(config, profiles)
for emu in ("advmame", "advmame-1.4", "advmame-0.94"):
with self.subTest(emu=emu):
placed = [
(f.get("root"), f.get("standalone_path"))
for view, standalone in platform_layouts(emu, profiles[emu], tags)
for view, standalone in platform_layouts(emu, profiles[emu], launches)
if standalone
for f in view["files"] if isinstance(f, dict) and f["name"] == "neogeo.zip"
]
@@ -1282,16 +1281,13 @@ class CoreOfferedOnSomeBoards(unittest.TestCase):
self.assertIsNone(boards[("puae2021", "amiga")])
def test_a_board_pack_places_the_core_where_the_board_offers_it(self) -> None:
from resolve.layout import CONTENT_FOLDER_PREFIX
from resolve.contentlayout import TARGET_KEY, content_folder_tags
from resolve.contentlayout import TARGET_KEY, content_launches
def placed(config: dict) -> dict:
rows = [json.loads(t[len(CONTENT_FOLDER_PREFIX):]) for t in content_folder_tags(config)
if t.startswith(CONTENT_FOLDER_PREFIX)]
return {core: on for core, _folder, _where, on in rows}
return {row.core: row.boards for row in content_launches(config).folders}
every = placed(self.config())
self.assertEqual(every["uae4arm"], ["h700", "rk3326"])
self.assertEqual(every["uae4arm"], ("h700", "rk3326"))
self.assertIsNone(every["puae"])
self.assertIn("uae4arm", placed(self.config(**{TARGET_KEY: "rk3326"})))
self.assertNotIn("uae4arm", placed(self.config(**{TARGET_KEY: "s922x"})))
+6 -6
View File
@@ -439,16 +439,16 @@ class TheSitePageOfACardPlatform(unittest.TestCase):
class TheWholeTreeKeepsCoresMinUILeavesOut(unittest.TestCase):
"""Without --platform, cross_reference and the site's gap report merge
every platform's standalone set. MinUI's per-core folders came along and
every platform's launches. MinUI's per-core folders came along and
left every core MinUI does not list with no layout: px68k showed 0 files
and the global report lost 238 profiles."""
def test_a_core_minui_does_not_list_keeps_its_files(self):
from resolve.standalone import merged_standalone_set, platform_layouts
from resolve.standalone import merged_launches, platform_layouts
minui = {"core_system_dirs": {"Bios/FC": {"cores": ["fceumm"]}}}
retroarch = {}
merged = merged_standalone_set([minui, retroarch], {})
merged = merged_launches([minui, retroarch], {})
profile = {"type": "libretro", "files": [{"name": "cgrom.tmp"}]}
layouts = platform_layouts("px68k", profile, merged)
self.assertEqual(layouts, [(profile, False)])
@@ -460,10 +460,10 @@ class TheWholeTreeKeepsCoresMinUILeavesOut(unittest.TestCase):
source = script_source(script)
with self.subTest(script=script):
self.assertTrue(
"merged_standalone_set(" in source or "global_report_scope(" in source
"merged_launches(" in source or "global_report_scope(" in source
)
self.assertNotIn("set().union(*(\n standalone_set(", source)
self.assertNotIn("*(standalone_set(cov", source)
self.assertNotIn("set().union(*(\n platform_launches(", source)
self.assertNotIn("*(platform_launches(cov", source)
if __name__ == "__main__":
+1 -1
View File
@@ -94,7 +94,7 @@ class CoreChoice(unittest.TestCase):
self.assertTrue(packprobe.libretro_build_runs("duckstation", both, {
"standalone_cores": ["duckstation"], "dual_mode_cores": ["duckstation-sa"]}, {}))
# A buildbot core installable under the standalone name is its
# libretro build, run both ways (standalone_set).
# libretro build, run both ways (platform_launches).
self.assertTrue(packprobe.libretro_build_runs("duckstation", both, {
"standalone_cores": ["duckstation"], "installable_cores": ["duckstation"]}, {}))
self.assertFalse(packprobe.libretro_build_runs("x", {"type": "standalone"}, {}, {}))
+8 -5
View File
@@ -16,10 +16,13 @@ from pathlib import Path
from packs import slotreport
from packs import slots as packs_slots
from resolve import collisions as resolve_collisions
from resolve.launches import PlatformLaunches
from packs.slots import Claim, Conflict, arbitrate
from packs.slotreport import format_decision
from tests.sources import script_source
ARES = PlatformLaunches(standalone=frozenset({"ares"}))
def _db(entries: dict[str, dict]) -> dict:
"""Minimal database shaped like the generated one, keyed by sha1.
@@ -699,7 +702,7 @@ class TestBuildModeDecidesWhoClaims(unittest.TestCase):
self._config(standalone=["ares"]),
self._profile(mode="standalone"),
REGIONS_DB,
standalone_cores={"ares"},
standalone_cores=ARES,
)
self.assertEqual(len(conflicts), 1)
@@ -708,7 +711,7 @@ class TestBuildModeDecidesWhoClaims(unittest.TestCase):
self._config(standalone=["ares"]),
self._profile(mode="libretro"),
REGIONS_DB,
standalone_cores={"ares"},
standalone_cores=ARES,
)
self.assertEqual(conflicts, [])
@@ -716,7 +719,7 @@ class TestBuildModeDecidesWhoClaims(unittest.TestCase):
claims = packs_slots.profile_claims(
self._profile(standalone_path="elsewhere/IPL.bin"),
REGIONS_DB,
standalone_cores={"ares"},
standalone_cores=ARES,
)
self.assertEqual(claims[0].destination, "elsewhere/IPL.bin")
@@ -728,7 +731,7 @@ class TestBuildModeDecidesWhoClaims(unittest.TestCase):
"mode": "standalone"}]}}
conflicts = packs_slots.find_conflicts(
self._config(standalone=["ares"]), profile, REGIONS_DB,
standalone_cores={"ares"},
standalone_cores=ARES,
)
self.assertEqual(len(conflicts), 1)
@@ -738,7 +741,7 @@ class TestBuildModeDecidesWhoClaims(unittest.TestCase):
"path": "GC/JAP/IPL.bin",
"standalone_path": "elsewhere/IPL.bin"}]}}
claims = packs_slots.profile_claims(
profile, REGIONS_DB, standalone_cores={"ares"}
profile, REGIONS_DB, standalone_cores=ARES
)
self.assertEqual(claims[0].destination, "GC/JAP/IPL.bin")
+25 -25
View File
@@ -22,11 +22,11 @@ from resolve.layout import (
entry_launch_systems,
standalone_bindings_for,
standalone_destination,
system_file_index,
)
from model.profiles import load_emulator_profiles
from model.platforms import load_platform_config
from resolve.standalone import platform_layouts, standalone_set
from resolve.launches import PlatformLaunches
from resolve.standalone import platform_layouts, platform_launches
from resolve.launchers import (
SEARCHED_FILES,
bound_path,
@@ -70,7 +70,7 @@ def config(*launchers: dict, base: str = "bios") -> dict:
def standalone_view(cfg: dict) -> dict:
views = platform_layouts("emu", PROFILE, standalone_set(cfg, {}))
views = platform_layouts("emu", PROFILE, platform_launches(cfg, {}))
return next(view for view, standalone in views if standalone)
@@ -309,7 +309,7 @@ class PerSystem(unittest.TestCase):
**config({**passes("emu", "bios/coco", "-rompath"), "systems": ["coco"]}),
"systems": {"coco": {"files": [{"name": "coco3.rom", "native_system": "coco"}]}},
}
index = system_file_index(standalone_set(cfg, {}))
index = platform_launches(cfg, {}).system_file_index()
self.assertEqual(
entry_launch_systems({"name": "COCO3.ROM", "system": "coco3"}, index),
frozenset({"coco3", "coco"}),
@@ -332,7 +332,7 @@ class SystemFamily(unittest.TestCase):
"systems": {"coco": {"native_id": "trs80coco",
"files": [{"name": "mc10.rom"}]}},
}
((view, _standalone),) = platform_layouts("emu", profile, standalone_set(cfg, {}))
((view, _standalone),) = platform_layouts("emu", profile, platform_launches(cfg, {}))
self.assertEqual(
[f.get("standalone_path") for f in view["files"]],
["trs80coco/mc10.rom", "trs80coco/alice.rom"],
@@ -356,7 +356,7 @@ class OfferedMachine(unittest.TestCase):
),
"systems": {"coco": {"files": [{"name": "x.zip", "native_system": "coco"}]}},
}
((view, _standalone),) = platform_layouts("emu", profile, standalone_set(cfg, {}))
((view, _standalone),) = platform_layouts("emu", profile, platform_launches(cfg, {}))
self.assertEqual(
[f.get("standalone_path") for f in view["files"]], ["coco/coco3.rom", "dragon/mc10.rom"]
)
@@ -382,7 +382,7 @@ class Layout(unittest.TestCase):
def test_libretro_view_keeps_path(self) -> None:
cfg = {**config(self.LINKED, base="BIOS"), "dual_mode_cores": ["emu"]}
views = platform_layouts("emu", PROFILE, standalone_set(cfg, {}))
views = platform_layouts("emu", PROFILE, platform_launches(cfg, {}))
libretro = next(view for view, standalone in views if not standalone)
self.assertIs(libretro, PROFILE)
@@ -392,7 +392,7 @@ class Layout(unittest.TestCase):
cfg = {**config(link("emu", "$biosdir/emu", "$home/.local/share/emu is a symlink to it"),
base="BIOS"), "dual_mode_cores": ["emu"]}
views = dict((standalone, view) for view, standalone in
platform_layouts("emu", PROFILE, standalone_set(cfg, {})))
platform_layouts("emu", PROFILE, platform_launches(cfg, {})))
self.assertEqual(
[f["path"] for f in views[False]["files"]], ["dc/boot.bin", "dc/set.zip", "dc/shared.bin"]
)
@@ -401,9 +401,9 @@ class Layout(unittest.TestCase):
)
def test_union_of_platforms_with_two_folders_keeps_the_profile_layout(self) -> None:
union = standalone_set(config(self.LINKED, base="BIOS"), {}) | standalone_set(config(
union = PlatformLaunches.merged([platform_launches(config(self.LINKED, base="BIOS"), {}), platform_launches(config(
link("emu", "${biosPath}/emu/bios", "symlink ${biosPath}/emu/bios -> ${HOME}/.local/share/emu"),
), {})
), {})])
self.assertEqual(standalone_bindings_for("emu", PROFILE, union), {})
def test_destination_function(self) -> None:
@@ -434,7 +434,7 @@ class FlycastOnEachPlatform(unittest.TestCase):
with self.subTest(platform=platform):
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
self.assertEqual(
standalone_bindings_for("flycast", self.profile, standalone_set(cfg, REPO_PROFILES)),
standalone_bindings_for("flycast", self.profile, platform_launches(cfg, REPO_PROFILES)),
{"": ("", folder)},
)
@@ -445,7 +445,7 @@ class FlycastOnEachPlatform(unittest.TestCase):
with self.subTest(platform=platform):
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
for view, standalone in platform_layouts(
"flycast", self.profile, standalone_set(cfg, REPO_PROFILES)
"flycast", self.profile, platform_launches(cfg, REPO_PROFILES)
):
if not standalone:
continue
@@ -463,7 +463,7 @@ class FlycastOnEachPlatform(unittest.TestCase):
self.assertIn("flycast", cfg.get("dual_mode_cores") or [])
views = {
standalone: view
for view, standalone in platform_layouts("flycast", self.profile, standalone_set(cfg, REPO_PROFILES))
for view, standalone in platform_layouts("flycast", self.profile, platform_launches(cfg, REPO_PROFILES))
}
self.assertEqual(set(views), {False, True})
for entry in views[False]["files"]:
@@ -594,7 +594,7 @@ class OpenmsxOnEachPlatform(unittest.TestCase):
with self.subTest(platform=platform):
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
self.assertEqual(
standalone_bindings_for("openmsx", self.profile, standalone_set(cfg, REPO_PROFILES)),
standalone_bindings_for("openmsx", self.profile, platform_launches(cfg, REPO_PROFILES)),
expected,
)
@@ -603,7 +603,7 @@ class OpenmsxOnEachPlatform(unittest.TestCase):
with self.subTest(platform=platform):
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
(view, _standalone), = platform_layouts(
"openmsx", self.profile, standalone_set(cfg, REPO_PROFILES)
"openmsx", self.profile, platform_launches(cfg, REPO_PROFILES)
)
for entry in view["files"]:
self.assertNotIn("unplaced", entry)
@@ -638,7 +638,7 @@ class XroarOnEachPlatform(unittest.TestCase):
def test_each_rom_lands_where_its_launch_reads_it(self) -> None:
for platform, folders in self.EXPECTED.items():
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
(view, _standalone), = platform_layouts("xroar", self.profile, standalone_set(cfg, REPO_PROFILES))
(view, _standalone), = platform_layouts("xroar", self.profile, platform_launches(cfg, REPO_PROFILES))
for entry in view["files"]:
with self.subTest(platform=platform, name=entry["name"]):
self.assertNotIn("unplaced", entry)
@@ -666,7 +666,7 @@ class AmiberryOnEachPlatform(unittest.TestCase):
with self.subTest(platform=platform):
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
self.assertEqual(
standalone_bindings_for(name, self.profiles[name], standalone_set(cfg, REPO_PROFILES)),
standalone_bindings_for(name, self.profiles[name], platform_launches(cfg, REPO_PROFILES)),
{"": ("", folder)},
)
@@ -674,7 +674,7 @@ class AmiberryOnEachPlatform(unittest.TestCase):
for platform, (name, folder) in self.BOUND.items():
profile = self.profiles[name]
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
views = platform_layouts(name, profile, standalone_set(cfg, REPO_PROFILES))
views = platform_layouts(name, profile, platform_launches(cfg, REPO_PROFILES))
((view, _standalone),) = [(v, s) for v, s in views if s]
for own, entry in zip(profile["files"], view["files"]):
if own.get("mode") == "libretro":
@@ -692,10 +692,10 @@ class AmiberryOnEachPlatform(unittest.TestCase):
profile = self.profiles[name]
cfg = load_platform_config("retrobat", str(REPO_ROOT / "platforms"))
self.assertEqual(
standalone_bindings_for(name, profile, standalone_set(cfg, REPO_PROFILES)),
standalone_bindings_for(name, profile, platform_launches(cfg, REPO_PROFILES)),
{"": ("emulators", "amiberry/ROMs"), "WHDBoot": ("emulators", "amiberry/WHDBoot")},
)
((view, _standalone),) = platform_layouts(name, profile, standalone_set(cfg, REPO_PROFILES))
((view, _standalone),) = platform_layouts(name, profile, platform_launches(cfg, REPO_PROFILES))
for own, entry in zip(profile["files"], view["files"]):
layout = own.get("standalone_path") or own.get("path") or own["name"]
folder = "amiberry" if layout.startswith("WHDBoot/") else "amiberry/ROMs"
@@ -746,7 +746,7 @@ class AmiberryBuildEachPlatformShips(unittest.TestCase):
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
if "amiberry" not in self.resolved(platform):
continue
layouts = platform_layouts("amiberry", self.profiles["amiberry"], standalone_set(cfg, REPO_PROFILES))
layouts = platform_layouts("amiberry", self.profiles["amiberry"], platform_launches(cfg, REPO_PROFILES))
with self.subTest(platform=platform):
self.assertEqual([standalone for _view, standalone in layouts], [False])
@@ -774,10 +774,10 @@ class AmiberryBuildEachPlatformShips(unittest.TestCase):
for name in ("amiberry-5.7.2", "amiberry-6.3.3"):
profile = self.profiles[name]
self.assertEqual(
standalone_bindings_for(name, profile, standalone_set(cfg, REPO_PROFILES)),
standalone_bindings_for(name, profile, platform_launches(cfg, REPO_PROFILES)),
{"kickstarts": ("", "amiga")},
)
((view, _standalone),) = platform_layouts(name, profile, standalone_set(cfg, REPO_PROFILES))
((view, _standalone),) = platform_layouts(name, profile, platform_launches(cfg, REPO_PROFILES))
for entry in view["files"]:
with self.subTest(name=name, file=entry["name"]):
if entry["path"].startswith("kickstarts/"):
@@ -793,10 +793,10 @@ class AmiberryBuildEachPlatformShips(unittest.TestCase):
profile = self.profiles["amiberry-5.6.5"]
cfg = load_platform_config("rocknix", str(REPO_ROOT / "platforms"))
self.assertEqual(
standalone_bindings_for("amiberry-5.6.5", profile, standalone_set(cfg, REPO_PROFILES)),
standalone_bindings_for("amiberry-5.6.5", profile, platform_launches(cfg, REPO_PROFILES)),
{"kickstarts": ("", "")},
)
((view, _standalone),) = platform_layouts("amiberry-5.6.5", profile, standalone_set(cfg, REPO_PROFILES))
((view, _standalone),) = platform_layouts("amiberry-5.6.5", profile, platform_launches(cfg, REPO_PROFILES))
for entry in view["files"]:
with self.subTest(name=entry["name"]):
if entry["path"].startswith("kickstarts/"):
+7 -6
View File
@@ -19,6 +19,7 @@ from pathlib import Path
import yaml
from packs.crossref import cross_reference
from resolve.launches import PlatformLaunches
REPO_ROOT = Path(__file__).resolve().parent.parent
@@ -76,10 +77,11 @@ class CrossReferenceReadsTheBuildThePlatformRuns(unittest.TestCase):
for Recalbox, which runs Dolphin standalone, it reported 12 Dolphin gaps
where verify and the pack builder found 26."""
def _gaps(self, standalone_cores):
def _gaps(self, standalone, dual=frozenset()):
empty_db = {"files": {}, "indexes": {}}
report = cross_reference(
{"dual": DUAL_PROFILE}, {}, empty_db, standalone_cores=standalone_cores
{"dual": DUAL_PROFILE}, {}, empty_db,
standalone_cores=PlatformLaunches(standalone=frozenset(standalone), dual=dual),
)
return sorted(g["name"] for g in report["dual"]["gap_details"])
@@ -93,10 +95,8 @@ class CrossReferenceReadsTheBuildThePlatformRuns(unittest.TestCase):
def test_a_platform_running_both_builds(self):
# The dual layout keyed seen files by (path, slot) and then looked
# the pair up in the slot table: KeyError on Batocera's dolphin.
from resolve.layout import DUAL_MODE_PREFIX
self.assertEqual(
self._gaps({"dual", DUAL_MODE_PREFIX + "dual"}),
self._gaps({"dual"}, dual=frozenset({"dual"})),
["both.bin", "libretro.bin", "standalone.bin"],
)
@@ -111,7 +111,8 @@ class CrossReferenceReadsTheBuildThePlatformRuns(unittest.TestCase):
],
}
report = cross_reference(
{"b": profile}, {}, {"files": {}, "indexes": {}}, standalone_cores={"b"}
{"b": profile}, {}, {"files": {}, "indexes": {}},
standalone_cores=PlatformLaunches(standalone=frozenset({"b"})),
)
self.assertEqual(len(report["b"]["gap_details"]), 2)
+2 -3
View File
@@ -308,9 +308,8 @@ class CoreDownloaderReach(unittest.TestCase):
"""Batocera runs amiberry standalone, and its x86_64 boards fetch
amiberry_libretro: removing every name the image builds lost the
libretro core to the name it shares with the standalone package."""
from resolve.layout import DUAL_MODE_PREFIX
from resolve.cores import resolve_platform_cores
from resolve.standalone import standalone_set
from resolve.standalone import platform_launches
from scraper.batocera_scraper import installable_cores
from scraper.targets.batocera_targets_scraper import BuildSelection
@@ -335,7 +334,7 @@ class CoreDownloaderReach(unittest.TestCase):
self.assertEqual(resolve_platform_cores(config, profiles), {"amiberry", "amiberry-7"})
self.assertEqual(resolve_platform_cores({**config, "installable_cores": []}, profiles),
{"amiberry-7"})
self.assertIn(DUAL_MODE_PREFIX + "amiberry", standalone_set(config, profiles))
self.assertIn("amiberry", platform_launches(config, profiles).dual)
class DownloadedCoresReachTheirBoards(unittest.TestCase):