From ec4a06e872924ef8ab0fafdc1926587290be6f9d Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 17 Oct 2026 11:54:05 +0200 Subject: [PATCH] fix: name a System.dat addition by its path --- scripts/exporter/systemdat_exporter.py | 8 ++++++-- tests/test_export_counts.py | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/exporter/systemdat_exporter.py b/scripts/exporter/systemdat_exporter.py index 3b198490..016c9d01 100644 --- a/scripts/exporter/systemdat_exporter.py +++ b/scripts/exporter/systemdat_exporter.py @@ -89,10 +89,14 @@ class Exporter(BaseExporter): libretro writes the path for some entries (ep128emu/roms/cpc464.rom) and the bare name for others whose destination has a directory all the same (iplromco.dat, which lives under keropi/), so its own - spelling is recorded rather than derived. + spelling is recorded rather than derived. An addition has no + spelling of libretro's to follow and is named by where the core reads + it: two PCSX2 convert.glsl shaders under one bare name were one line. """ declared = fe.native("native_path", "") - return str(declared) if declared else fe.name + if declared: + return str(declared) + return fe.destination if fe.platform is None else fe.name def _header(self, originals: dict[str, str], scraped: dict | None) -> list[str]: """Reuse the original header verbatim when we have the original.""" diff --git a/tests/test_export_counts.py b/tests/test_export_counts.py index f35e4726..3d399afc 100644 --- a/tests/test_export_counts.py +++ b/tests/test_export_counts.py @@ -242,6 +242,22 @@ class PureDataExportsKeepWhatWeDoNotModel(unittest.TestCase): self.assertIn('\tcomment "New - System"', produced) + def test_two_additions_differing_by_directory_are_two_lines(self): + """PCSX2's vulkan and opengl convert.glsl were both written under the + bare name; the second was dropped and still counted as added.""" + from exporter.baseline import Report + + shaders = [ + NativeFile("convert.glsl", f"pcsx2/resources/shaders/{api}/convert.glsl", + "Sony - PlayStation 2", truth={"md5": digest * 32}) + for api, digest in (("vulkan", "a"), ("opengl", "b")) + ] + systems = {"Sony - PlayStation 2": NativeSystem("Sony - PlayStation 2", files=shaders)} + produced = SystemDat().render(systems, Report(), {})["System.dat"] + self.assertIn("name pcsx2/resources/shaders/vulkan/convert.glsl md5 " + "a" * 32, produced) + self.assertIn("name pcsx2/resources/shaders/opengl/convert.glsl md5 " + "b" * 32, produced) + self.assertEqual(SystemDat().validate(systems, {"System.dat": produced}), []) + class EmuDeckWritesItsCorrections(unittest.TestCase): """A correction replaced nothing: every withdrawal was refused, the run counted the correction anyway and validate failed on it."""