refactor: one upstream name index for core lookups

This commit is contained in:
Abdessamad Derraz committed 2026-10-06 01:47:16 +02:00
1 parent 994836938c
commit ca86236c12
6 files changed
+121 -42

No files matched your search

+2 -2
View File
@@ -149,8 +149,8 @@ class CoreResolutionTests(unittest.TestCase):
def test_index_maps_key_and_every_core_alias(self):
index = cf.profile_name_index(self.PROFILES)
self.assertEqual(index["mednafen_psx"], "beetle_psx")
self.assertEqual(index["beetle_psx"], "beetle_psx")
self.assertEqual(index["mednafen_psx"], {"beetle_psx"})
self.assertEqual(index["beetle_psx"], {"beetle_psx"})
def test_unresolved_honours_remove_cores_per_target(self):
index = cf.profile_name_index(self.PROFILES)
+3 -3
View File
@@ -1659,8 +1659,8 @@ class TestE2E(unittest.TestCase):
config = {
"platform": "TestStandalone",
"verification_mode": "existence",
"cores": ["test_emu"],
"standalone_cores": ["test_emu"],
"cores": ["test_sa"],
"standalone_cores": ["test_sa"],
"systems": {
"console-a": {
"files": [
@@ -1680,7 +1680,7 @@ class TestE2E(unittest.TestCase):
emu = {
"emulator": "TestStandaloneEmu",
"type": "standalone + libretro",
"cores": ["test_emu"],
"cores": ["test_sa"],
"systems": ["console-a"],
"files": [
{
+51
View File
@@ -0,0 +1,51 @@
"""One reverse index from upstream core names to profiles.
Five copies broke ties differently. The target branch of
resolve_platform_cores kept the last profile claiming a name, so the
buildbot's `pcsx2` (the LRPS2 core) mapped to the standalone pcsx2 profile
and a RetroArch target pack lost LRPS2's files.
"""
from __future__ import annotations
import re
import sys
import unittest
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import ( # noqa: E402
preferred_profile,
resolve_platform_cores,
upstream_profile_index,
)
PROFILES = {
"lrps2": {"type": "libretro", "cores": ["lrps2", "pcsx2"]},
"pcsx2": {"type": "standalone", "cores": ["pcsx2"]},
}
class OneIndex(unittest.TestCase):
def test_target_keeps_every_claimant(self):
config = {"cores": "all_libretro"}
self.assertEqual(
resolve_platform_cores(config, PROFILES, target_cores={"pcsx2"}), {"lrps2"}
)
def test_platform_list_prefers_the_key(self):
config = {"cores": ["pcsx2"]}
self.assertEqual(resolve_platform_cores(config, PROFILES), {"pcsx2"})
self.assertEqual(preferred_profile(upstream_profile_index(PROFILES), "pcsx2"), "pcsx2")
def test_no_hand_made_index(self):
pattern = re.compile(r"(upstream_to_profile|core_to_profile)\[[^\]]+\]\s*=")
for path in sorted((REPO_ROOT / "scripts").rglob("*.py")):
with self.subTest(module=path.name):
self.assertIsNone(pattern.search(path.read_text(encoding="utf-8")))
if __name__ == "__main__":
unittest.main()