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")