From ce135b788fca52f3e5341d283de4a779f501e216 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 6 Oct 2026 04:49:21 +0200 Subject: [PATCH] fix: compare only the full pack to verify --- scripts/generate_pack.py | 4 ++-- scripts/pipeline.py | 33 +++++++++++++++++++++++++-------- tests/test_audit_regressions.py | 10 ++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index 7e0a2b06..8e78ddd3 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -2271,9 +2271,9 @@ def _run_platform_packs( for p in group_platforms ] label = " / ".join(all_names) - print(f"\nGenerating pack for {label} [source={source}]...") + print(f"\nGenerating pack for {label} [source={source}{', required' if required_only else ''}]...") else: - print(f"\nGenerating pack for {representative} [source={source}]...") + print(f"\nGenerating pack for {representative} [source={source}{', required' if required_only else ''}]...") try: tc = target_cores_cache.get(representative) if args.target else None diff --git a/scripts/pipeline.py b/scripts/pipeline.py index 98f38918..26d746cf 100644 --- a/scripts/pipeline.py +++ b/scripts/pipeline.py @@ -81,11 +81,17 @@ def parse_pack_counts(output: str) -> dict[str, tuple[int, int]]: for line in output.splitlines(): m = re.match(r"Generating (?:shared )?pack for (.+)\.\.\.", line) if m: - # Labels carry execution metadata such as ``[source=full]``. - # It is not part of the platform identity used for consistency. - current_label = re.sub( - r"\s+\[source=[^\]]+\]$", "", m.group(1).strip() - ) + # Labels carry execution metadata such as ``[source=full]``. Only + # the full, unreduced pack is what verify describes: with + # --all-variants the six variants shared one label and the last + # (platform, required) was compared to the full report. + label = m.group(1).strip() + meta = re.search(r"\s+\[([^\]]+)\]$", label) + current_label = label[: meta.start()] if meta else label + if meta and meta.group(1) != "source=full": + current_label = "" + continue + if not current_label: continue if "files packed" not in line: continue @@ -557,8 +563,14 @@ def main(): print("\n--- 4c/8 generate target manifests: SKIPPED (--skip-packs) ---") results["generate_target_manifests"] = SKIPPED - # Step 5: Consistency check - if pack_output and verify_output: + # Step 5: Consistency check. verify describes the full pack; a run that + # built only a reduced one (--source platform or truth) has nothing to + # compare it with, and says so instead of failing on an empty parse. + full_pack_built = args.source == "full" or args.all_variants + if pack_output and verify_output and not full_pack_built: + print("\n--- 5/8 consistency check: SKIPPED (no full pack built) ---") + results["consistency"] = SKIPPED + elif pack_output and verify_output: ok = check_consistency(verify_output, pack_output) results["consistency"] = ok all_ok = all_ok and ok @@ -567,7 +579,12 @@ def main(): results["consistency"] = SKIPPED # Step 6: Pack integrity (extract + hash verification) - if not args.skip_packs: + if not args.skip_packs and not full_pack_built: + # The check reads the full pack's name; a reduced pack holds fewer + # files than the platform declares by design. + print("\n--- 6/8 pack integrity: SKIPPED (no full pack built) ---") + results["pack_integrity"] = SKIPPED + elif not args.skip_packs: integrity_cmd = [ sys.executable, "scripts/generate_pack.py", diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 8c24bc3c..4d75d9e5 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -492,6 +492,16 @@ class PipelineRegressions(unittest.TestCase): with contextlib.redirect_stdout(io.StringIO()): self.assertFalse(pipeline.check_consistency(verify, pack)) + def test_only_the_full_variant_feeds_the_comparison(self): + """--all-variants printed six packs under one label; the last won.""" + output = "\n".join([ + "Generating pack for RetroArch [source=full]...", + " a.zip: 5 files packed (5 baseline + 0 from cores), 535/535 files OK", + "Generating pack for RetroArch [source=platform, required]...", + " b.zip: 5 files packed (5 baseline + 0 from cores), 530/530 files OK", + ]) + self.assertEqual(pipeline.parse_pack_counts(output), {"RetroArch": (535, 535)}) + def test_slot_step_reaches_the_summary(self): source = Path(pipeline.__file__).read_text(encoding="utf-8") self.assertIn('results["slots"] = ok', source)