fix: list systems the way --system selects

This commit is contained in:
Abdessamad Derraz committed 2026-10-09 22:57:15 +02:00
1 parent 6207e81d9c
commit d295e51ad6
2 files changed
+31 -7

No files matched your search

+14 -7
View File
@@ -1709,17 +1709,24 @@ def list_emulator_profiles(emulators_dir: str, skip_aliases: bool = True) -> Non
def list_system_ids(emulators_dir: str) -> None:
"""Print available system IDs with emulator count."""
"""Print available system IDs with emulator count.
Counted on the normalized id, as --system selects: listed per spelling,
3do showed two emulators and panasonic-3do six for one system.
"""
profiles = load_emulator_profiles(emulators_dir)
system_emus: dict[str, list[str]] = {}
for name, p in profiles.items():
system_emus: dict[str, set[str]] = {}
spelling: dict[str, str] = {}
for name, p in sorted(profiles.items()):
if p.get("type") in ("alias", "test", "launcher"):
continue
for sys_id in p.get("systems", []):
system_emus.setdefault(sys_id, []).append(name)
for sys_id in sorted(system_emus):
count = len(system_emus[sys_id])
print(f" {sys_id:35s} ({count} emulator{'s' if count > 1 else ''})")
key = _norm_system_id(sys_id)
system_emus.setdefault(key, set()).add(name)
spelling.setdefault(key, sys_id)
for key in sorted(system_emus, key=lambda k: spelling[k]):
count = len(system_emus[key])
print(f" {spelling[key]:35s} ({count} emulator{'s' if count > 1 else ''})")
def list_platform_system_ids(platform_name: str, platforms_dir: str) -> None:
+17
View File
@@ -40,6 +40,23 @@ class SpellingsAgree(unittest.TestCase):
self.assertEqual(builder._system_display_name("msxturboR"), builder._system_display_name("msxturbor"))
class TheListingCountsLikeTheSelection(unittest.TestCase):
def test_one_system_is_listed_once_with_every_profile(self):
import contextlib # noqa: PLC0415
import io # noqa: PLC0415
out = io.StringIO()
with contextlib.redirect_stdout(out):
common.list_system_ids(str(REPO_ROOT / "emulators"))
lines = {line.split()[0]: line for line in out.getvalue().splitlines() if line.strip()}
profiles = common.load_emulator_profiles(str(REPO_ROOT / "emulators"))
for spellings in (("3do", "panasonic-3do"), ("atari-2600", "atari_2600")):
listed = [s for s in spellings if s in lines]
self.assertEqual(len(listed), 1, f"{spellings}: one line per system")
count = len(common.profiles_for_systems(profiles, [spellings[0]]))
self.assertIn(f"({count} emulator", lines[listed[0]])
class StandaloneNeedsAStandaloneBuild(unittest.TestCase):
def test_a_custom_pack_refuses_it_for_a_libretro_core(self):
with tempfile.TemporaryDirectory() as tmp: