From c2bdef4db458663ffd040521e8956ff6ade4c8e9 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 10 Oct 2026 10:04:35 +0200 Subject: [PATCH] fix: pair a bare truth name by name, not suffix --- scripts/exporter/baseline.py | 7 ++++++- tests/test_exporters.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/exporter/baseline.py b/scripts/exporter/baseline.py index cebb25d9..09799d81 100644 --- a/scripts/exporter/baseline.py +++ b/scripts/exporter/baseline.py @@ -325,8 +325,13 @@ def build_native_model( def by_destination(candidate: NativeFile, t_dest: str = t_dest) -> bool: # Dolphin writes dolphin-emu/Sys/GC/USA/IPL.bin for the truth's # GC/USA/IPL.bin: a destination ending in the path is the file. + # A bare name is no path: dc/boot.bin ends in /boot.bin, and + # fbneo's 480-byte boot.bin is not that 2 MB Dreamcast BIOS. + # Names go through by_name and its size guard. theirs = _match_key(candidate.platform or {})[0] - return bool(t_dest) and (theirs == t_dest or theirs.endswith("/" + t_dest)) + if not t_dest: + return False + return theirs == t_dest or ("/" in t_dest and theirs.endswith("/" + t_dest)) def by_name( candidate: NativeFile, diff --git a/tests/test_exporters.py b/tests/test_exporters.py index 50e4fcaf..d98a04ac 100644 --- a/tests/test_exporters.py +++ b/tests/test_exporters.py @@ -120,6 +120,22 @@ def model(truth: dict = TRUTH, scraped: dict | None = SCRAPED): class Reconciliation(unittest.TestCase): """The platform's file corrected, not replaced by ours.""" + def test_a_bare_truth_name_is_not_a_path_suffix(self): + """fbneo's boot.bin has no path; libretro's dc/boot.bin ends in + /boot.bin. The suffix paired them past the size guard and wrote the + 480-byte file's size and hashes over the 2 MB Dreamcast BIOS.""" + truth = {"systems": {"sega-dreamcast": {"files": [ + {"name": "boot.bin", "size": 480, "crc32": "f0774fc2"}]}}} + scraped = {"systems": {"sega-dreamcast": {"native_id": "dc", "files": [ + {"name": "boot.bin", "destination": "dc/boot.bin", "native_system": "dc", + "size": 2097152, "crc32": "89f2b1a1"}]}}} + systems, report = build_native_model(truth, scraped) + platform_entry = next( + fe for fe in systems["dc"].files if fe.destination == "dc/boot.bin" + ) + self.assertIsNone(platform_entry.truth) + self.assertEqual(report.hashes_corrected, []) + def test_a_file_the_truth_says_nothing_about_is_kept(self): systems, _ = model() names = {fe.name for fe in systems["psx"].files}