fix: open no System.dat section libretro lacks

libretro titles each section with the system as it spells it,
"Commodore - Amiga". An addition for a system it has no section for
opened one under our slug: 21 sections came out as commodore-c64,
quake, laseractive or xrick, which no libretro DAT carries. An addition
now lands only in a section the original holds and is otherwise counted
as left out, so the export keeps the original's 66 sections. A platform
entry is always written, under its own section.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 17:21:16 +02:00
1 parent a8226dd367
commit f957b5f893
4 files changed
+61 -6

No files matched your search

+5 -1
View File
@@ -4226,7 +4226,11 @@ class TestE2E(unittest.TestCase):
from exporter.baseline import build_native_model
systems, report = build_native_model(truth, {"systems": {}})
produced = SystemDatExporter().render(systems, report, {}, {"systems": {}})
original = ('clrmamepro (\n\tname "System"\n)\n\ngame (\n\tname "System"\n'
'\tcomment "commodore-plus4"\n)\n')
produced = SystemDatExporter().render(
systems, report, {"System.dat": original}, {"systems": {}}
)
self.assertIn("crc 70295038", produced["System.dat"])
# ---------------------------------------------------------------
+3 -1
View File
@@ -275,7 +275,9 @@ class PureDataExportsKeepWhatWeDoNotModel(unittest.TestCase):
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"]
original = ('clrmamepro (\n\tname "System"\n)\n\ngame (\n\tname "System"\n'
'\tcomment "Sony - PlayStation 2"\n)\n')
produced = SystemDat().render(systems, Report(), {"System.dat": original})["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}), [])
+32 -2
View File
@@ -1206,6 +1206,38 @@ class RommKeepsItsFixture(unittest.TestCase):
self.assertEqual(len(changed), 2, changed)
class SystemDatNamesNoSectionItself(unittest.TestCase):
"""libretro titles each section with the system as it spells it,
"Commodore - Amiga". An addition for a system it has no section for
opened one under our slug: 20 such sections, commodore-c64, quake,
laseractive."""
def test_an_addition_without_a_libretro_section_is_left_out(self):
amiga = "Commodore - Amiga"
original = (
'clrmamepro (\n\tname "System"\n)\n\ngame (\n\tname "System"\n'
f'\tcomment "{amiga}"\n'
f"\trom ( name kick34005.A500 size 262144 md5 {'2' * 32} )\n"
")\n"
)
scraped = {"systems": {"commodore-amiga": {"native_id": amiga, "files": [
{"name": "kick34005.A500", "destination": "kick34005.A500",
"native_system": amiga, "md5": "2" * 32, "size": 262144}]}}}
truth = {"systems": {
"commodore-amiga": {"files": [{"name": "kick40068.A1200", "md5": "3" * 32}]},
"laseractive": {"files": [{"name": "pac-n1.bin", "crc32": "a8cb694c"}]},
}}
systems, report = build_native_model(truth, scraped)
exporter = discover_exporters()["retroarch"]()
produced = exporter.render(systems, report, {"System.dat": original}, None)["System.dat"]
self.assertNotIn('comment "laseractive"', produced)
self.assertNotIn("pac-n1.bin", produced)
self.assertIn("kick40068.A1200", produced)
self.assertEqual(exporter.validate(systems, {"System.dat": produced}), [])
added = systems["laseractive"].files[0]
self.assertFalse(exporter.lands(added))
class SystemDatKeepsSpaceIndentedLines(unittest.TestCase):
"""libretro indents 39 rom lines with four spaces. Read with a tab only,
they left the base and came back last in their section, re-indented."""
@@ -1508,8 +1540,6 @@ class BatoceraExport(unittest.TestCase):
exporter = discover_exporters()[platform]
self.assertFalse(exporter().writable(foreign))
self.assertTrue(exporter().writable(own))
# A format that finds files by path has no system key to miss.
self.assertTrue(discover_exporters()["retroarch"]().writable(foreign))
produced = discover_exporters()["batocera"]().render(
systems, report, {"batocera-systems": self.SKELETON}, None
)