From ccb35b9b82a69b62e7178050691b0332ec97d2ec Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 17 Oct 2026 10:38:18 +0200 Subject: [PATCH] refactor: read the preferred-entry rule from packresolve --- scripts/verify.py | 4 +++- tests/test_audit_regressions.py | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/verify.py b/scripts/verify.py index 295ea503..8d5777cc 100644 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -783,7 +783,9 @@ def _twin_index( verify_systems: dict, db: dict, base_dest: str, zip_contents: dict, ) -> tuple[dict[str, int], dict[int, tuple[str, dict]]]: """Which declaration the pack ships at each destination, and every declaration by id.""" - from generate_pack import _preferred_entries + # From the module that defines the rule, not the builder's CLI: importing + # generate_pack made every verify depend on its argparse and manifest code. + from packresolve import preferred_entries as _preferred_entries preferred_entries = _preferred_entries( verify_systems, db, DEFAULT_BIOS_DIR, base_dest, False, diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index f0240a69..bed061eb 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -2520,6 +2520,27 @@ class GeneratedModelsAreWrittenWhole(unittest.TestCase): self.assertTrue((bios / "Arcade" / "MAME" / "setclone.zip").exists()) +class APackNoteBesideItsSlotIsANote(unittest.TestCase): + """The builder writes INSTRUCTIONS_.txt beside the slot it + explains; verify_pack recognised notes at the ZIP root only and failed + a pack holding games/keen6/INSTRUCTIONS_egagraph.ck6.txt.""" + + def test_a_nested_note_is_not_hashed_against_the_collection(self): + from scripts.packverify import verify_pack + + with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory: + path = Path(directory) / "Pack.zip" + with zipfile.ZipFile(path, "w") as archive: + archive.writestr("games/keen6/INSTRUCTIONS_egagraph.ck6.txt", "File needed") + archive.writestr("bios/RENAMED_x.bin.txt", "renamed") + result = verify_pack(str(path), {"files": {}, "indexes": {}}) + self.assertTrue(result[0], result) + + def test_verify_reads_the_rule_where_it_is_defined(self): + source = (ROOT / "scripts" / "verify.py").read_text(encoding="utf-8") + self.assertNotIn("from generate_pack import _preferred_entries", source) + + class TheDatabaseCacheIsWrittenWhole(unittest.TestCase): """A crash while serializing left a truncated db_cache.json behind, and the next run rehashed the whole collection from scratch."""