fix: split only the systems the target runs

--split --target asked for a part per declared system, and each one
the target drops ended on a refusal naming it unknown (finding 14).
This commit is contained in:
Abdessamad Derraz committed 2026-11-05 11:47:37 +01:00
1 parent c7df790744
commit 7f31cf37cf
2 files changed
+40 -3

No files matched your search

+5 -3
View File
@@ -1940,7 +1940,11 @@ def generate_split_packs(
split_dir = os.path.join(output_dir, f"{part_prefix}{group_tag}_Split")
os.makedirs(split_dir, exist_ok=True)
systems = config.get("systems", {})
if emu_profiles is None:
emu_profiles = load_emulator_profiles(emulators_dir)
# The systems a core of the target runs: a part per declared system sent
# each one the target drops to a refusal naming it as unknown.
systems = platform_scope_systems(config, emu_profiles, target_cores)
if group_by == "manufacturer":
groups = _group_systems_by_manufacturer(systems, db, bios_dir)
@@ -1949,8 +1953,6 @@ def generate_split_packs(
# Pre-compute core extras once (expensive: scans 260+ emulator profiles)
# then distribute per group based on emulator system overlap
if emu_profiles is None:
emu_profiles = load_emulator_profiles(emulators_dir)
base_dest = config.get("base_destination", "")
# Each part cuts the platform's own entries from the full profiles. The
# extras are collected once here, already without the cores' game data.
+35
View File
@@ -128,5 +128,40 @@ class ASystemTheTargetDropsIsNamedAsSuch(unittest.TestCase):
proc.stderr)
class ASplitBuildsOnlyTheTargetsSystems(unittest.TestCase):
"""`--split --target switch` asked for a part per declared system, and
each one the target drops ended on 'retroarch has no system matching'."""
def test_no_part_is_asked_for_a_dropped_system(self):
from unittest import mock
import generate_pack
from common import load_emulator_profiles
platforms = str(REPO_ROOT / "platforms")
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
asked: list[list[str]] = []
def record(*_a, **kw):
if kw.get("system_filter"):
asked.append(kw["system_filter"])
return None
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as out, \
mock.patch.object(generate_pack, "generate_pack", record), \
mock.patch.object(generate_pack, "_collect_emulator_extras",
return_value=[]):
generate_pack.generate_split_packs(
"retroarch", platforms, {"files": {}}, "bios", out,
emu_profiles=profiles,
target_cores=_target_cores_for("retroarch", "switch", platforms),
target_name="nintendo-switch",
)
systems = {sid for ids in asked for sid in ids}
self.assertTrue(systems)
self.assertNotIn("sony-playstation-2", systems)
self.assertIn("sony-playstation", systems)
if __name__ == "__main__":
unittest.main()