diff --git a/scripts/cross_reference.py b/scripts/cross_reference.py index b9aaa16e..c94645ed 100644 --- a/scripts/cross_reference.py +++ b/scripts/cross_reference.py @@ -435,7 +435,11 @@ class FileConsumers: for name, config in configs.items(): for system_id, system in config.get("systems", {}).items(): for entry in system.get("files", []): - sha1 = self.sha1_of(entry, entry.get("destination", "")) + # No destination hint, as the builder, the manifest and + # verify resolve a declaration: with one, RetroBat's 63 + # mame/hash lists credited another revision than the one + # its manifest installs. + sha1 = self.sha1_of(entry) if sha1: self.platforms.setdefault(sha1, set()).add(name) self.platform_systems.setdefault(sha1, {}).setdefault( diff --git a/tests/test_file_consumers.py b/tests/test_file_consumers.py index 94b23f13..df11a77a 100644 --- a/tests/test_file_consumers.py +++ b/tests/test_file_consumers.py @@ -83,6 +83,36 @@ class ReadersResolve(unittest.TestCase): self.assertNotIn("ioquake3", et) +class PlatformReadersResolveAsThePack(unittest.TestCase): + """A hashless declaration resolves without its destination in the + builder, the manifest and verify. The site passed the destination and + credited RetroBat with another revision of its 63 mame/hash lists than + the one its manifest installs.""" + + def test_the_declared_file_is_the_one_the_pack_ships(self): + from packresolve import resolve_declaration + + first, first_entry = _collected("bios/Arcade/MAME/hash/apfm1000.xml", b"one") + other, other_entry = _collected("bios/Other/mame/hash/apfm1000.xml", b"two") + db = { + "files": {first: first_entry, other: other_entry}, + "indexes": { + "by_name": {"apfm1000.xml": [first, other]}, + "by_path_suffix": {"mame/hash/apfm1000.xml": [other], + "Other/mame/hash/apfm1000.xml": [other], + "MAME/hash/apfm1000.xml": [first], + "Arcade/MAME/hash/apfm1000.xml": [first]}, + }, + } + entry = {"name": "apfm1000.xml", "destination": "mame/hash/apfm1000.xml"} + shipped, _status = resolve_declaration(entry, db, "bios", None, None, None, + offline=True) + consumers = FileConsumers(db, data_dir_registry={}) + consumers.add_platforms({"plat": {"systems": {"s": {"files": [entry]}}}}) + self.assertEqual(shipped, first_entry["path"]) + self.assertEqual(consumers.platforms, {first: {"plat"}}) + + class ReadersFollowTheDataTrees(unittest.TestCase): """Dolphin names codehandler.bin without a hash. The pack takes it from data/dolphin-sys, and the site credited Dolphin and Triforce with the