test: cover the emulator pack's own build path

generate_emulator_pack is a distinct build path from the platform packs,
and nothing asserted that it produced the same bytes twice. It does, but
only because every member write was routed through one writer: restoring
the mtime-copying write on that path alone fails the new test and no
other.
This commit is contained in:
Abdessamad Derraz committed 2026-08-23 06:53:15 +02:00
1 parent a269f9b677
commit 77b06bcb1b
1 file changed
+46
+46
View File
@@ -275,6 +275,52 @@ class TestPackDeterminism(unittest.TestCase):
for info in generated:
self.assertEqual(info.date_time, _FIXED_DATE_TIME)
def _build_emulator(self, out_name: str) -> Path:
from scripts.generate_pack import generate_emulator_pack
out = self.tmp / out_name
out.mkdir()
(self.tmp / "emulators").mkdir(exist_ok=True)
(self.tmp / "emulators" / "detcore.yml").write_text(
"emulator: detcore\n"
"type: libretro\n"
"display_name: DetCore\n"
"systems: [test-sys]\n"
"cores: [detcore]\n"
"files:\n"
" - name: boot.rom\n"
" system: test-sys\n"
" required: true\n"
" - name: romset.zip\n"
" system: test-sys\n"
" required: true\n"
)
import common
common._emulator_profiles_cache.clear()
path = generate_emulator_pack(
["detcore"], str(self.tmp / "emulators"), self.db, str(self.bios),
str(out), offline=True,
)
common._emulator_profiles_cache.clear()
self.assertIsNotNone(path)
return Path(path)
def test_an_emulator_pack_is_byte_identical_too(self):
"""A distinct build path, and one the platform packs do not cover."""
first = self._build_emulator("emu1")
time.sleep(2.1)
second = self._build_emulator("emu2")
self.assertEqual(
hashlib.sha256(first.read_bytes()).hexdigest(),
hashlib.sha256(second.read_bytes()).hexdigest(),
)
def test_every_emulator_pack_member_carries_the_fixed_epoch(self):
pack = self._build_emulator("emu1")
with zipfile.ZipFile(pack) as zf:
self.assertEqual({i.date_time for i in zf.infolist()}, {_FIXED_DATE_TIME})
def test_injected_manifest_is_pinned_to_the_database(self):
from scripts.generate_pack import inject_manifest, verify_pack