diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index fcfb75fc..85ae1477 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -2497,8 +2497,10 @@ def _run_verify_packs(args: argparse.Namespace) -> None: set(os.listdir(args.output_dir)) if os.path.isdir(args.output_dir) else set() ) + verified = 0 for platform_name in platforms: found = sorted(expected[platform_name] & on_disk) + verified += len(found) if not found: # Naming a platform is asking about its pack: FAIL, with the # command that builds it. With --all, a platform whose pack was @@ -2545,6 +2547,11 @@ def _run_verify_packs(args: argparse.Namespace) -> None: print(f" {err}") all_ok = False + if not verified: + # Every platform skipped is no check at all: a mistyped or purged + # output directory read as a passed integrity check. + print(f"ERROR: no pack to verify in {args.output_dir}") + all_ok = False if not all_ok: sys.exit(1) diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index 6fbe31f5..203de47f 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -5019,6 +5019,18 @@ class ANamedPackThatIsAbsentFails(unittest.TestCase): self.assertIn("retroarch: FAIL (no pack in", result.stdout) self.assertIn("generate_pack.py --platform retroarch", result.stdout) + def test_all_with_no_pack_is_a_failure(self): + """--all on a mistyped or purged directory skipped every platform + and exited 0, a passed integrity check that checked nothing.""" + with tempfile.TemporaryDirectory(dir=TMP_ROOT) as directory: + result = subprocess.run( + [sys.executable, "scripts/generate_pack.py", "--all", + "--verify-packs", "--output-dir", directory], + cwd=ROOT, capture_output=True, text=True, timeout=600, + ) + self.assertEqual(result.returncode, 1) + self.assertIn("no pack to verify", result.stdout) + class AnAliasNamesItsProfile(unittest.TestCase):