fix: name custom and system packs by their selection

Two --from-md5 runs with different hash lists wrote the same file, the
second replacing the first, and a pack limited to thirty systems built
a name longer than a file name may be. The custom pack now carries a
digest of its hash list, and a long system list keeps its first system,
a count and a digest, as the emulator pack does.
This commit is contained in:
Abdessamad Derraz committed 2026-10-17 10:28:11 +02:00
1 parent 3f68547dc3
commit 7a6e494597
2 files changed
+44 -3

No files matched your search

+16
View File
@@ -2238,6 +2238,22 @@ class APackNameFitsAFileName(unittest.TestCase):
self.assertNotEqual(long_name, other)
self.assertEqual(_bounded_pack_name(["A", "B"], ["a", "b"], ".zip"), "A_B.zip")
def test_a_long_system_list_is_bounded(self):
"""Thirty systems joined made a 261-byte platform pack name."""
from scripts.generate_pack import MAX_SYSTEM_TAG_BYTES, _system_tag
systems = [f"vendor-console-number-{i}" for i in range(30)]
tag = _system_tag(systems)
self.assertLessEqual(len(tag.encode()), MAX_SYSTEM_TAG_BYTES + 1)
self.assertNotEqual(tag, _system_tag(systems[:-1] + ["other-console"]))
self.assertEqual(_system_tag(["sony-playstation"]), "_Playstation")
def test_two_hash_lists_get_two_names(self):
"""--from-md5 named its pack after the context only: a second list
overwrote the first pack in the same directory."""
source = (ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8")
self.assertIn('_Custom_{selection}', source)
def test_the_system_pack_names_itself(self):
source = (ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8")
self.assertIn("pack_name=final_name", source)