From 9ca1e68007cecdf09b6da222da74246651e9ff8a Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sun, 18 Oct 2026 16:20:50 +0200 Subject: [PATCH] fix: word the alias refusal as a sentence --- scripts/common.py | 14 ++++++++++++-- tests/test_audit_regressions.py | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/scripts/common.py b/scripts/common.py index f5b7ab66..2c408de1 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -1651,9 +1651,19 @@ def select_emulator_profiles( profile = all_profiles[name] kind = profile.get("type", "libretro") if kind == "alias": + # An alias without alias_of is found through the profile whose + # cores: names it, as the buildbot reverse index does. + target = profile.get("alias_of") or next( + ( + key for key, value in all_profiles.items() + if value.get("type") != "alias" and name in (value.get("cores") or []) + ), + None, + ) raise ProfileSelectionError( - f"{name} is an alias of {profile.get('alias_of', '?')} " - f"-use --emulator {profile.get('alias_of', '?')}" + f"{name} is an alias of {target}: use --emulator {target}" + if target + else f"{name} is an alias with no profile of its own to name" ) if kind == "launcher": raise ProfileSelectionError( diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 0bf569c8..44c47600 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -4968,5 +4968,27 @@ class ANamedPackThatIsAbsentFails(unittest.TestCase): self.assertIn("generate_pack.py --platform retroarch", result.stdout) + +class AnAliasNamesItsProfile(unittest.TestCase): + """"flycast_gles2 is an alias of flycast -use --emulator flycast": the + dash read as an option, and an alias without alias_of advised + "--emulator ?".""" + + def test_the_message(self): + from scripts.common import ProfileSelectionError, select_emulator_profiles + + profiles = { + "flycast": {"type": "libretro", "cores": ["flycast", "flycast_gles2"]}, + "flycast_gles2": {"type": "alias", "alias_of": "flycast"}, + "orphan": {"type": "alias"}, + "core": {"type": "libretro", "cores": ["orphan"]}, + } + for name, expected in (("flycast_gles2", "alias of flycast: use --emulator flycast"), + ("orphan", "alias of core: use --emulator core")): + with self.subTest(name=name), self.assertRaises(ProfileSelectionError) as caught: + select_emulator_profiles([name], profiles) + self.assertIn(expected, str(caught.exception)) + + if __name__ == "__main__": unittest.main()