mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 21:43:23 -05:00
fix: one agnostic substitute rule for pack and verify
This commit is contained in:
1 parent
cf7d9ecb89
commit
36f7ee0b2b
6 files changed
+152
-34
No files matched your search
@@ -0,0 +1,60 @@
|
||||
"""Pack, verify and manifest answer the same way for a filename-agnostic core.
|
||||
|
||||
The pack alone renamed any PS2 image into a missing slot, even on an md5
|
||||
platform whose frontend then rejects it, and counted it OK; verify called
|
||||
the slot missing and the manifest omitted it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
from validation import agnostic_substitute # noqa: E402
|
||||
|
||||
|
||||
class AgnosticSubstitute(unittest.TestCase):
|
||||
def test_only_the_platform_cores_answer(self):
|
||||
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
|
||||
held = Path(tmp) / "ps2" / "scph39001.bin"
|
||||
held.parent.mkdir()
|
||||
held.write_bytes(b"x" * 16)
|
||||
db = {
|
||||
"files": {"a": {"path": str(held), "name": "scph39001.bin", "size": 16}},
|
||||
"indexes": {"by_name": {"scph39001.bin": ["a"]}},
|
||||
}
|
||||
agnostic = {
|
||||
"bios_mode": "agnostic",
|
||||
"systems": ["sony-playstation-2"],
|
||||
"files": [{"name": "scph39001.bin", "min_size": 8}],
|
||||
}
|
||||
self.assertEqual(
|
||||
agnostic_substitute({}, "sony-playstation-2", db, {"pcsx2": agnostic}),
|
||||
(str(held), f"{held.parent}/"),
|
||||
)
|
||||
self.assertIsNone(agnostic_substitute({}, "sony-playstation-2", db, {}))
|
||||
self.assertIsNone(agnostic_substitute({}, "nintendo-nes", db, {"pcsx2": agnostic}))
|
||||
self.assertIsNone(
|
||||
agnostic_substitute({"md5": "0" * 32}, "sony-playstation-2", db, {"pcsx2": agnostic})
|
||||
)
|
||||
|
||||
def test_every_reader_calls_it_behind_the_existence_gate(self):
|
||||
builder = (REPO_ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8")
|
||||
verify = (REPO_ROOT / "scripts" / "verify.py").read_text(encoding="utf-8")
|
||||
self.assertEqual(builder.count("agnostic_substitute(file_entry, sys_id"), 2)
|
||||
self.assertEqual(verify.count("agnostic_substitute(file_entry, sys_id"), 1)
|
||||
for source in (builder, verify):
|
||||
for call in re.finditer(r"agnostic_substitute\(file_entry, sys_id", source):
|
||||
window = source[max(0, call.start() - 300):call.start()]
|
||||
self.assertIn("reads_file_contents", window)
|
||||
self.assertNotIn('_emu_prof.get("bios_mode")', builder)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+15
-2
@@ -848,6 +848,13 @@ class TestE2E(unittest.TestCase):
|
||||
r = check_inside_zip(self.files["bad_inner.zip"]["path"], "inner.rom", "wrong")
|
||||
self.assertEqual(r, "untested")
|
||||
|
||||
def test_20b_agnostic_core_fills_existence_slots(self):
|
||||
"""An agnostic core on the platform serves a missing slot, as the pack does."""
|
||||
config = load_platform_config("test_existence", self.platforms_dir)
|
||||
result = verify_platform(config, self.db, self.emulators_dir)
|
||||
c = result["severity_counts"]
|
||||
self.assertEqual(c[Severity.OK], result["total_files"])
|
||||
|
||||
def test_13_check_inside_zip_not_found(self):
|
||||
r = check_inside_zip(self.files["missing_inner.zip"]["path"], "nope.rom", "abc")
|
||||
self.assertEqual(r, "not_in_zip")
|
||||
@@ -859,7 +866,13 @@ class TestE2E(unittest.TestCase):
|
||||
|
||||
def test_20_verify_existence_platform(self):
|
||||
config = load_platform_config("test_existence", self.platforms_dir)
|
||||
result = verify_platform(config, self.db, self.emulators_dir)
|
||||
# Without the filename-agnostic core, which would serve the two
|
||||
# missing slots under existence (test_20b covers that case).
|
||||
profiles = {
|
||||
k: v for k, v in load_emulator_profiles(self.emulators_dir).items()
|
||||
if v.get("bios_mode") != "agnostic"
|
||||
}
|
||||
result = verify_platform(config, self.db, self.emulators_dir, emu_profiles=profiles)
|
||||
c = result["severity_counts"]
|
||||
total = result["total_files"]
|
||||
# 2 present (1 req + 1 opt), 2 missing (1 req WARNING + 1 opt INFO)
|
||||
@@ -3704,7 +3717,7 @@ class TestE2E(unittest.TestCase):
|
||||
zip_names = {
|
||||
n
|
||||
for n in zf.namelist()
|
||||
if not n.startswith("INSTRUCTIONS_")
|
||||
if not n.startswith(("INSTRUCTIONS_", "RENAMED_"))
|
||||
and n != "manifest.json"
|
||||
and n != "README.txt"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user