fix: write the MiSTer database on one line

The BiosDB is published as a single line of JSON without a final
newline. Written with indent=2 it came out as 1499 changed lines for a
database whose content had not changed, which would bury any real
correction. It is now written in MiSTer's own form: an empty truth
gives back the cached database byte for byte.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 18:54:28 +02:00
1 parent 3ed5f68b82
commit 804534397f
2 files changed
+19 -1

No files matched your search

+3 -1
View File
@@ -105,7 +105,9 @@ class Exporter(BaseExporter):
if size:
entry["size"] = size
return {_DB_NAME: json.dumps(database, indent=2, ensure_ascii=False) + "\n"}
# MiSTer publishes the database as one line, without a final
# newline: written with an indent it came out as 1499 changed lines.
return {_DB_NAME: json.dumps(database, ensure_ascii=False)}
def validate(
self,
+16
View File
@@ -1420,6 +1420,22 @@ class BizhawkExport(unittest.TestCase):
self.assertFalse(exporter.states(entry, "sha1"))
class MisterDatabaseComesBackAsWritten(unittest.TestCase):
"""The BiosDB is one line of JSON. Written with indent=2 it came out as
1499 changed lines for a database whose content had not changed."""
def test_an_empty_truth_hands_back_the_database(self):
archive = UPSTREAM_CACHE / "misterfpga" / "bios_db.json.zip"
if not archive.exists():
self.skipTest("upstream cache not populated")
exporter = discover_exporters()["misterfpga"]()
originals = exporter.unpack(archive.read_bytes())
config = native_layer(load_platform_config("misterfpga", str(REPO_ROOT / "platforms")))
systems, report = build_native_model({"systems": {}}, config)
produced = exporter.render(systems, report, originals, config)
self.assertEqual(produced, originals)
class RetrodeckManifestsComeBackAsWritten(unittest.TestCase):
"""With nothing to correct, a manifest is the platform's own bytes. The
export added a final newline to nine of ten, wrote "md5": null where no