From a6eda07b8ab3e396f2aefd7e61d0b47a4c9616e5 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 21 Oct 2026 10:06:52 +0200 Subject: [PATCH] fix: end --verify-packs on a summary line The check ended on the last platform's line: a failing pack was named only above its own errors. It now names every failing pack on stderr at the end, as the build path does, or counts the packs found OK. --- scripts/generate_pack.py | 12 ++++++++++++ tests/test_verify_pack_choice.py | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index 417d9437..dbd70406 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -2588,6 +2588,7 @@ def _run_verify_packs(args: argparse.Namespace) -> None: ) verified = 0 + failing: list[str] = [] for platform_name in platforms: found = sorted(expected[platform_name] & on_disk) verified += len(found) @@ -2601,6 +2602,7 @@ def _run_verify_packs(args: argparse.Namespace) -> None: f"generate_pack.py --platform {platform_name} --output-dir {args.output_dir})" ) all_ok = False + failing.append(f"{platform_name} (no pack)") else: print(f" {platform_name}: SKIP (no pack in {args.output_dir})") continue @@ -2646,7 +2648,17 @@ def _run_verify_packs(args: argparse.Namespace) -> None: for err in errors: print(f" {err}") all_ok = False + failing.append(f"{platform_name} ({pack_name})") + if failing: + # Named at the end, where the log is read, and on stderr, as the + # build path does: a failing pack sat among its own error lines. + print( + f"ERROR: packs failed verification: {', '.join(failing)}", + file=sys.stderr, + ) + elif verified: + print(f"Verified {verified} pack{'s' if verified != 1 else ''}: all OK") if not verified: # Every platform skipped is no check at all: a mistyped or purged # output directory read as a passed integrity check. diff --git a/tests/test_verify_pack_choice.py b/tests/test_verify_pack_choice.py index 0de0a352..75ab4c5f 100644 --- a/tests/test_verify_pack_choice.py +++ b/tests/test_verify_pack_choice.py @@ -115,6 +115,30 @@ class VerifyPackChoice(unittest.TestCase): for name in names[1:]: self.assertIn(f"[{name}]: hashes checked during the build", printed) + def test_the_run_ends_on_a_summary(self): + """A failing pack was named only above its own error lines, and the + log ended on the last platform's OK line.""" + import contextlib + import io + + pack = f"{self.stem}_BIOS_Pack.zip" + self._touch(pack) + out, err = io.StringIO(), io.StringIO() + failed = (False, 0, 0, ["x: missing"], 1, 0, 1, 1, 0) + with mock.patch.object(self.gp, "verify_pack_against_platform", + return_value=failed), \ + contextlib.redirect_stdout(out), contextlib.redirect_stderr(err), \ + self.assertRaises(SystemExit): + self.gp._run_verify_packs(self._args()) + self.assertEqual( + err.getvalue().strip().splitlines()[-1], + f"ERROR: packs failed verification: retroarch ({pack})", + ) + out = io.StringIO() + with contextlib.redirect_stdout(out): + self._run(self._args()) + self.assertEqual(out.getvalue().strip().splitlines()[-1], "Verified 1 pack: all OK") + def test_include_archived_reaches_the_archived_pack(self): stem = self.gp._platform_pack_stem(["retropie"], "retropie", "platforms") self._touch(f"{stem}_BIOS_Pack.zip")