refactor: share the core file lookup with verify

verify replayed the builder's placement of core files with a bare name lookup, without the archive index, the data directories or the core's own choice of copy. It compared other bytes than the pack's (blueMSX's MSX2P.rom from bios/ against the data tree's copy) and let an unresolved file take a path the builder leaves free. ExtraResolver now holds the builder's lookup and both call it.
This commit is contained in:
Abdessamad Derraz committed 2026-10-19 23:08:12 +02:00
1 parent 2bd9f8a264
commit 8fd8437351
5 files changed
+123 -22

No files matched your search

+5 -1
View File
@@ -2711,6 +2711,9 @@ class ARegionDroppedExtraBlocksNothing(unittest.TestCase):
with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory:
other = Path(directory) / "FOO.ROM"
other.write_bytes(b"other bytes")
first = Path(directory) / "foo.rom"
first.write_bytes(b"first bytes")
copies = {"foo.rom": str(first), "FOO.ROM": str(other)}
extras = [
{"name": "foo.rom", "destination": "foo.rom", "source_emulator": "a"},
{"name": "FOO.ROM", "destination": "FOO.ROM", "source_emulator": "b"},
@@ -2721,7 +2724,8 @@ class ARegionDroppedExtraBlocksNothing(unittest.TestCase):
with mock.patch.object(packextras, "_collect_emulator_extras",
return_value=extras), \
mock.patch.object(packextras, "resolve_local_file",
return_value=(str(other), "name_exact")):
side_effect=lambda fe, *a, **k: (
copies[fe["name"]], "name_exact")):
return packextras.hidden_extras(
config, "emulators", {"files": {}}, {}, {}, None, region_drops
)
+33
View File
@@ -154,5 +154,38 @@ class TheGapReportIsComputedOnce(unittest.TestCase):
self.assertEqual(counted.call_count, 1)
class TheReplayResolvesAsTheBuilder(unittest.TestCase):
"""verify replayed the builder's placement with a bare name lookup: it
compared other bytes than the pack's, and an extra it could not resolve
still took its path and blocked the next one the builder places."""
def test_an_unresolved_extra_blocks_nothing(self):
from unittest import mock
import packextras
extras = [
{"destination": "box.bin/inner.rom", "name": "inner.rom",
"source_emulator": "a", "source_name": "inner.rom", "source_path": ""},
{"destination": "box.bin", "name": "box.bin",
"source_emulator": "b", "source_name": "box.bin", "source_path": ""},
]
class Resolver:
def resolve(self, fe, dest):
return (None, "not_found", "") if fe["name"] == "inner.rom" else (
"bios/box.bin", "sha1_exact", ""
)
placed: set[str] = set()
with mock.patch.object(packextras, "_collect_emulator_extras", return_value=extras):
hidden = packextras.hidden_extras(
{"systems": {}}, "emulators", {"files": {}}, {}, {},
placed=placed, resolver=Resolver(),
)
self.assertEqual(hidden, {})
self.assertEqual(placed, {"box.bin"})
if __name__ == "__main__":
unittest.main()