mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-23 20:29:06 -05:00
fix: match profile_sync --system as verify does
--system compared the raw id, so the normalized spelling printed by verify.py --list-systems selected 1 Saturn profile of 11. The hint now counts the spellings that listing prints.
This commit is contained in:
1 parent
6877512af7
commit
3d2a521f8a
2 files changed
+36
-3
No files matched your search
+15
-3
@@ -30,7 +30,13 @@ import yaml
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
import upstream
|
||||
from common import github_token, load_emulator_profiles, suggest_names
|
||||
from common import (
|
||||
_norm_system_id,
|
||||
github_token,
|
||||
load_emulator_profiles,
|
||||
suggest_names,
|
||||
system_index,
|
||||
)
|
||||
from hashing import parse_hash_list
|
||||
from sourceref import ( # noqa: F401 (re-exported for callers and tests) # noqa: F401 (the prose grammar, re-exported)
|
||||
_ANNOTATION_RE,
|
||||
@@ -3589,11 +3595,16 @@ def select_profiles(profiles: dict, args: argparse.Namespace) -> dict:
|
||||
)
|
||||
return {args.emulator: profiles[args.emulator]}
|
||||
|
||||
# --system matches as verify.py --list-systems lists and --system selects:
|
||||
# by normalized id, so `saturn` reaches the profiles declaring sega-saturn.
|
||||
wanted_system = _norm_system_id(args.system) if args.system else None
|
||||
selected = {}
|
||||
for name, profile in sorted(profiles.items()):
|
||||
if profile.get("type") in ("alias", "test"):
|
||||
continue
|
||||
if args.system and args.system not in (profile.get("systems") or []):
|
||||
if wanted_system and wanted_system not in {
|
||||
_norm_system_id(str(s)) for s in profile.get("systems") or []
|
||||
}:
|
||||
continue
|
||||
if args.type_ and profile.get("type") != args.type_:
|
||||
continue
|
||||
@@ -3615,7 +3626,8 @@ def select_profiles(profiles: dict, args: argparse.Namespace) -> dict:
|
||||
)
|
||||
hint = ""
|
||||
if args.system:
|
||||
systems = sorted({s for p in profiles.values() for s in p.get("systems") or []})
|
||||
# Suggested from the spellings the named listing prints.
|
||||
systems = sorted(spelling for spelling, _ in system_index(profiles).values())
|
||||
hint = " " + suggest_names([args.system], systems, "verify.py --list-systems")
|
||||
elif args.type_:
|
||||
kinds = sorted({str(p.get("type")) for p in profiles.values() if p.get("type")})
|
||||
|
||||
@@ -4399,6 +4399,27 @@ class TestSelectionNamesWhatMatchedNothing(unittest.TestCase):
|
||||
selected = profile_sync.select_profiles(self.PROFILES, self._args(system="atari-lynx"))
|
||||
self.assertEqual(sorted(selected), ["handy", "mednafen_lynx"])
|
||||
|
||||
def test_system_matches_as_the_listing_does(self):
|
||||
"""verify.py --list-systems printed `saturn`, which selected 1 profile
|
||||
of 11 because 10 declare sega-saturn."""
|
||||
profiles = {
|
||||
"a": {"type": "libretro", "systems": ["sega-saturn"]},
|
||||
"b": {"type": "libretro", "systems": ["saturn"]},
|
||||
}
|
||||
for spelling in ("saturn", "sega-saturn"):
|
||||
selected = profile_sync.select_profiles(profiles, self._args(system=spelling))
|
||||
self.assertEqual(sorted(selected), ["a", "b"])
|
||||
|
||||
def test_the_hint_counts_what_the_listing_prints(self):
|
||||
profiles = {
|
||||
"a": {"type": "libretro", "systems": ["sega-saturn"]},
|
||||
"b": {"type": "libretro", "systems": ["saturn"]},
|
||||
"c": {"type": "libretro", "systems": ["atari-lynx"]},
|
||||
}
|
||||
with self.assertRaises(SystemExit) as caught:
|
||||
profile_sync.select_profiles(profiles, self._args(system="nothing"))
|
||||
self.assertIn("Known: atari-lynx, sega-saturn.", str(caught.exception.code))
|
||||
|
||||
|
||||
|
||||
class TestTreeUrlIntoADirectory(unittest.TestCase):
|
||||
|
||||
Reference in new issue
Block a user