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.
This commit is contained in:
Abdessamad Derraz committed 2026-10-21 10:06:52 +02:00
1 parent 8c7c705169
commit a6eda07b8a
2 files changed
+36

No files matched your search

+12
View File
@@ -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.
+24
View File
@@ -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")