mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 09:37:48 -06:00
fix: count one export line per addition path
This commit is contained in:
1 parent
651c64c763
commit
144cd46df1
4 files changed
+113
-14
No files matched your search
@@ -827,6 +827,70 @@ class SearchOrder(unittest.TestCase):
|
||||
self.assertEqual(entry.priority, 2)
|
||||
|
||||
|
||||
class TwoAdditionsAtOnePath(unittest.TestCase):
|
||||
"""Two cores declaring two dumps of one file the platform lacks: both
|
||||
were counted added while the render wrote one. Recalbox's md5 list takes
|
||||
both, a System.dat name and a RetroDECK path hold one."""
|
||||
|
||||
A, B = "615a" + "0" * 28, "ef49" + "0" * 28
|
||||
|
||||
def _addition(self, md5: str, core: str, system: str = "dos") -> NativeFile:
|
||||
return NativeFile(
|
||||
name="MT32_CONTROL.ROM", destination="mt32/MT32_CONTROL.ROM", native_system=system,
|
||||
truth={"name": "MT32_CONTROL.ROM", "path": "mt32/MT32_CONTROL.ROM", "md5": md5,
|
||||
"crc32": md5[:8], "required": True, "_cores": [core]},
|
||||
runners=[(False, core)],
|
||||
)
|
||||
|
||||
def _added(self, exporter, systems) -> list[str]:
|
||||
return [c["name"] for c in landed_changes(exporter, systems).records
|
||||
if c["kind"] == "added"]
|
||||
|
||||
def test_recalbox_writes_both_md5_in_one_element(self):
|
||||
systems = {"dos": NativeSystem("dos", files=[
|
||||
self._addition(self.A, "dosbox_pure"), self._addition(self.B, "dosbox_core")])}
|
||||
exporter = discover_exporters()["recalbox"]()
|
||||
produced = exporter.render(systems, Report(), {})["es_bios.xml"]
|
||||
elements = [e for e in ET.fromstring(produced).iter("bios")]
|
||||
self.assertEqual(len(elements), 1)
|
||||
self.assertEqual(elements[0].get("md5").split(","), [self.A, self.B])
|
||||
self.assertEqual(elements[0].get("core"), "libretro/dosbox_pure,libretro/dosbox_core")
|
||||
self.assertEqual(exporter.validate(systems, {"es_bios.xml": produced}), [])
|
||||
self.assertEqual(len(self._added(exporter, systems)), 2)
|
||||
|
||||
def test_system_dat_counts_the_line_it_wrote(self):
|
||||
systems = {"DOS": NativeSystem("DOS", files=[
|
||||
self._addition(self.A, "dosbox_pure", "DOS"),
|
||||
self._addition(self.B, "dosbox_core", "DOS")])}
|
||||
exporter = discover_exporters()["retroarch"]()
|
||||
original = 'clrmamepro (\n\tname "System"\n)\n\ngame (\n\tname "System"\n' \
|
||||
'\tcomment "System"\n\n\tcomment "DOS"\n\trom ( name a.bin size 1 crc 00000000 )\n)\n'
|
||||
produced = exporter.render(systems, Report(), {"System.dat": original})["System.dat"]
|
||||
self.assertEqual(produced.count("MT32_CONTROL.ROM"), 1)
|
||||
self.assertEqual(len(self._added(exporter, systems)), 1)
|
||||
|
||||
def test_retrodeck_counts_the_entry_it_appended(self):
|
||||
theirs = NativeFile(
|
||||
name="scph1001.bin", destination="scph1001.bin", native_system="psx",
|
||||
platform={"name": "scph1001.bin", "md5": "1" * 32, "component": "duckstation"})
|
||||
|
||||
def addition(md5: str) -> NativeFile:
|
||||
return NativeFile(
|
||||
name="scph5501.bin", destination="scph5501.bin", native_system="psx",
|
||||
truth={"name": "scph5501.bin", "md5": md5, "required": True,
|
||||
"_cores": ["duckstation"]},
|
||||
runners=[(True, "duckstation")])
|
||||
|
||||
systems = {"psx": NativeSystem("psx", files=[theirs, addition(self.A), addition(self.B)])}
|
||||
manifest = json.dumps({"duckstation": {"name": "DuckStation", "bios": [
|
||||
{"filename": "scph1001.bin", "md5": "1" * 32, "system": "psx"}]}})
|
||||
exporter = discover_exporters()["retrodeck"]()
|
||||
produced = exporter.render(systems, Report(), {"duckstation/component_manifest.json": manifest})
|
||||
bios = json.loads(produced["duckstation/component_manifest.json"])["duckstation"]["bios"]
|
||||
self.assertEqual([e["filename"] for e in bios], ["scph1001.bin", "scph5501.bin"])
|
||||
self.assertEqual(self._added(exporter, systems), ["scph5501.bin"])
|
||||
|
||||
|
||||
class AdditionOrder(unittest.TestCase):
|
||||
"""What we add is listed the way the code looks for it."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user