From 0f293b6c141922fab304d66d69ea0770d571e796 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 6 Oct 2026 12:52:24 +0200 Subject: [PATCH] fix: slot emulator entries where the pack puts them --- scripts/verify.py | 10 ++++-- tests/test_verify_emulator_evidence.py | 45 ++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/scripts/verify.py b/scripts/verify.py index 632a3e36..aa35f1ce 100644 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -1279,6 +1279,8 @@ def verify_emulator( A region priority list narrows the report the same way a pack built with the same list would be narrowed, through the emulator pack's own drop set. """ + from packpaths import _resolve_destination + load_emulator_profiles(emulators_dir) zip_contents = build_zip_contents_index(db) @@ -1312,8 +1314,6 @@ def verify_emulator( standalone, ) if region_drops: - from packpaths import _resolve_destination - structure = profile.get("pack_structure") files = [ fe @@ -1501,7 +1501,11 @@ def verify_emulator( result["system"] = file_entry.get("system", "") result["hle_fallback"] = hle result["ground_truth"] = build_ground_truth(name, validation_index) - dest = file_entry.get("path", "") or name + # The slot the emulator pack places this entry in: standalone_path + # under --standalone, the pack_structure prefix, the sanitised path. + dest = _resolve_destination( + file_entry, profile.get("pack_structure"), standalone + ) or name emu_results.setdefault(dest, []).append((result, required, hle)) for dest, alternatives in emu_results.items(): diff --git a/tests/test_verify_emulator_evidence.py b/tests/test_verify_emulator_evidence.py index a103234d..e70dc7a9 100644 --- a/tests/test_verify_emulator_evidence.py +++ b/tests/test_verify_emulator_evidence.py @@ -363,5 +363,50 @@ class RepositoryWideEvidence(unittest.TestCase): print(f"\n entries resolving to hash_mismatch: {len(offenders)}") + +class StandaloneSlotsFollowThePack(unittest.TestCase): + """verify_emulator keyed its slots by `path` while the emulator pack places + and dedups by standalone_path under --standalone: two entries the pack + ships to two folders were one alternative in the report.""" + + def setUp(self): + self._tmp = tempfile.TemporaryDirectory() + self.root = Path(self._tmp.name) + self.emulators = self.root / "emulators" + self.emulators.mkdir() + rom = self.root / "a.rom" + rom.write_bytes(b"one rom read from two folders") + self.db = _db(rom, "a.rom") + (self.emulators / "dual.yml").write_text( + "emulator: dual\n" + "type: standalone + libretro\n" + "systems: [demo-system]\n" + "files:\n" + " - name: a.rom\n" + " path: bios/a.rom\n" + " standalone_path: A/a.rom\n" + " - name: a.rom\n" + " path: bios/a.rom\n" + " standalone_path: B/a.rom\n" + ) + from common import _emulator_profiles_cache + + _emulator_profiles_cache.clear() + + def tearDown(self): + from common import _emulator_profiles_cache + + _emulator_profiles_cache.clear() + self._tmp.cleanup() + + def test_each_standalone_folder_is_a_slot(self): + standalone = verify.verify_emulator( + ["dual"], str(self.emulators), self.db, standalone=True + ) + core = verify.verify_emulator(["dual"], str(self.emulators), self.db) + self.assertEqual(standalone["total_files"], 2) + self.assertEqual(core["total_files"], 1) + + if __name__ == "__main__": unittest.main()