From bc68e517cb30c2d2507b6c54bc35bbb7ea8d0188 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 21 Oct 2026 05:19:27 +0200 Subject: [PATCH] fix: suggest the closest system for --platform --platform retroarch --system sony-playstaton listed the first ten systems of the alphabet. The warning now names the closest systems and the command that lists the platform's own, as --system alone already did. --- scripts/generate_pack.py | 10 +++++++--- tests/test_audit_regressions.py | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index 6c2a5b51..cf209d3e 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -769,10 +769,14 @@ def generate_pack( if sid in system_filter or _norm_system_id(sid) in norm_filter } if not filtered: - available = sorted(pack_systems.keys())[:10] + hint = suggest_names( + system_filter, + sorted(pack_systems), + f"--platform {platform_name} --list-systems", + ) print( - f" WARNING: no systems matched filter {system_filter} " - f"(available: {', '.join(available)})" + f" WARNING: {platform_name} has no system matching " + f"{', '.join(system_filter)}. {hint}" ) return None pack_systems = filtered diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index c098693b..49c738e1 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -5884,5 +5884,27 @@ class InstallerJsonKindsNeverOverwriteEachOther(unittest.TestCase): self.assertEqual(after, before) +class PlatformSystemTypoGetsTheClosestNames(unittest.TestCase): + """--platform retroarch --system sony-playstaton listed the first ten + systems of the alphabet, 3do to coleco-colecovision.""" + + def test_the_hint_names_the_close_systems(self): + from scripts import generate_pack as gp + + out = io.StringIO() + with tempfile.TemporaryDirectory(dir=TMP_ROOT) as tmp, \ + contextlib.redirect_stdout(out): + result = gp.generate_pack( + "retroarch", str(ROOT / "platforms"), {"files": {}, "indexes": {}}, + str(ROOT / "bios"), tmp, emulators_dir=str(ROOT / "emulators"), + system_filter=["sony-playstaton"], offline=True, + ) + self.assertIsNone(result) + printed = out.getvalue() + self.assertIn("Did you mean: sony-playstation", printed) + self.assertIn("--platform retroarch --list-systems", printed) + self.assertNotIn("3do", printed) + + if __name__ == "__main__": unittest.main()