mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 13:33:24 -05:00
fix: test extras grouping through the real chain
This commit is contained in:
1 parent
15842d6402
commit
fd8db894d8
3 files changed
+33
-32
No files matched your search
@@ -3798,7 +3798,6 @@ from packextras import ( # noqa: E402,F401
|
|||||||
_detect_extras_prefix,
|
_detect_extras_prefix,
|
||||||
_detect_slug_structure,
|
_detect_slug_structure,
|
||||||
_map_emulator_to_slug,
|
_map_emulator_to_slug,
|
||||||
_emulator_systems_index,
|
|
||||||
_collect_emulator_extras,
|
_collect_emulator_extras,
|
||||||
_extra_system_ids,
|
_extra_system_ids,
|
||||||
platform_region_groups,
|
platform_region_groups,
|
||||||
|
|||||||
@@ -15,22 +15,7 @@ from common import runs_standalone
|
|||||||
from common import sanitize_pack_path
|
from common import sanitize_pack_path
|
||||||
from common import size_fits
|
from common import size_fits
|
||||||
from validation import read_from_system_dir
|
from validation import read_from_system_dir
|
||||||
def _emulator_systems_index(emu_profiles: dict | None) -> dict[str, list[str]]:
|
|
||||||
"""Map both the profile key and its display name to the profile's systems.
|
|
||||||
|
|
||||||
find_undeclared_files reports the display name ("Beetle PSX (Mednafen
|
|
||||||
PSX)"), while the profile dictionary is keyed by slug. A key-only lookup
|
|
||||||
therefore missed almost every core, dropping its files into one shared
|
|
||||||
bucket and losing the per-system grouping the narrowing passes rely on.
|
|
||||||
"""
|
|
||||||
index: dict[str, list[str]] = {}
|
|
||||||
for key, profile in (emu_profiles or {}).items():
|
|
||||||
systems = list(profile.get("systems", []))
|
|
||||||
index[key] = systems
|
|
||||||
display = profile.get("emulator", "")
|
|
||||||
if display:
|
|
||||||
index.setdefault(display, systems)
|
|
||||||
return index
|
|
||||||
|
|
||||||
def _detect_extras_prefix(config: dict, base_dest: str) -> str:
|
def _detect_extras_prefix(config: dict, base_dest: str) -> str:
|
||||||
"""The prefix core-extra destinations take (may be empty).
|
"""The prefix core-extra destinations take (may be empty).
|
||||||
|
|||||||
+33
-16
@@ -6151,26 +6151,43 @@ struct BurnDriver BurnDrvneogeo = {
|
|||||||
self.assertIn("sony-playstation", readme)
|
self.assertIn("sony-playstation", readme)
|
||||||
|
|
||||||
def test_extras_group_under_their_system_not_a_shared_bucket(self):
|
def test_extras_group_under_their_system_not_a_shared_bucket(self):
|
||||||
"""find_undeclared_files reports the display name, the profiles are
|
"""A core extra competes in its system's group: the chain from the
|
||||||
keyed by slug; a key-only lookup put nearly every core extra in one
|
gap report (system, systems) to platform_region_groups, not a
|
||||||
bucket and lost the per-system grouping both narrowing passes need."""
|
dictionary built by hand. Without it every extra stood alone and
|
||||||
from generate_pack import _emulator_systems_index
|
--region compared nothing."""
|
||||||
|
import hashlib # noqa: PLC0415
|
||||||
|
|
||||||
index = _emulator_systems_index(
|
from packextras import platform_region_groups # noqa: PLC0415
|
||||||
{
|
|
||||||
"beetle_psx": {
|
files, by_name = {}, {}
|
||||||
"emulator": "Beetle PSX (Mednafen PSX)",
|
for name in ("core_us.bin", "core_jp.bin"):
|
||||||
"systems": ["sony-playstation"],
|
payload = name.encode()
|
||||||
},
|
path = os.path.join(self.bios_dir, name)
|
||||||
"beebem": {"emulator": "beebem", "systems": ["bbc-micro-b"]},
|
with open(path, "wb") as handle:
|
||||||
}
|
handle.write(payload)
|
||||||
|
sha1 = hashlib.sha1(payload).hexdigest()
|
||||||
|
files[sha1] = {"path": path, "name": name, "size": len(payload),
|
||||||
|
"md5": hashlib.md5(payload).hexdigest()}
|
||||||
|
by_name[name] = [sha1]
|
||||||
|
db = {"files": files, "indexes": {"by_name": by_name, "by_md5": {},
|
||||||
|
"by_crc32": {}, "by_path_suffix": {}}}
|
||||||
|
profiles = {"psxcore": {
|
||||||
|
"emulator": "PSX Core (Display Name)", "type": "libretro",
|
||||||
|
"systems": ["sony-playstation"],
|
||||||
|
"files": [{"name": "core_us.bin", "region": ["north-america"]},
|
||||||
|
{"name": "core_jp.bin", "region": ["japan"]}],
|
||||||
|
}}
|
||||||
|
config = {"platform": "P", "cores": ["psxcore"], "base_destination": "system",
|
||||||
|
"systems": {"sony-playstation": {"files": [
|
||||||
|
{"name": "declared.bin", "destination": "declared.bin"}]}}}
|
||||||
|
groups, _ = platform_region_groups(
|
||||||
|
config, config["systems"], self.emulators_dir, db, "system", profiles,
|
||||||
)
|
)
|
||||||
self.assertEqual(index["beetle_psx"], ["sony-playstation"])
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
index["Beetle PSX (Mednafen PSX)"], ["sony-playstation"]
|
sorted(groups["sony-playstation"]),
|
||||||
|
[("core_jp.bin", "core_jp.bin"), ("core_us.bin", "core_us.bin"),
|
||||||
|
("declared.bin", "declared.bin")],
|
||||||
)
|
)
|
||||||
self.assertEqual(index["beebem"], ["bbc-micro-b"])
|
|
||||||
self.assertNotIn("_extras", index)
|
|
||||||
|
|
||||||
def test_slot_narrowed_pack_gets_its_own_name(self):
|
def test_slot_narrowed_pack_gets_its_own_name(self):
|
||||||
names = {
|
names = {
|
||||||
|
|||||||
Reference in new issue
Block a user