diff --git a/scripts/refresh_data_dirs.py b/scripts/refresh_data_dirs.py index a00bbf8f..81905b74 100644 --- a/scripts/refresh_data_dirs.py +++ b/scripts/refresh_data_dirs.py @@ -544,6 +544,15 @@ def main() -> None: if args.key not in registry: log.error("unknown key: %s (available: %s)", args.key, ", ".join(registry)) raise SystemExit(1) + allowed = registry[args.key].get("for_platforms") + if args.platform and allowed and args.platform not in allowed: + # The platform restriction applied only without --key: dolphin-sys + # was refreshed for RomM, which never reads it. + log.error( + "%s does not serve %s (for_platforms: %s)", + args.key, args.platform, ", ".join(allowed), + ) + raise SystemExit(2) outcomes = { args.key: refresh_entry( args.key, registry[args.key], force=args.force, dry_run=args.dry_run diff --git a/tests/test_refresh_failures.py b/tests/test_refresh_failures.py index 07db23a7..ef589050 100644 --- a/tests/test_refresh_failures.py +++ b/tests/test_refresh_failures.py @@ -138,5 +138,22 @@ class TheVersionIsReadBeforeTheDownload(unittest.TestCase): self.assertEqual(json.loads(versions.read_text())["sys"]["sha"], "build-1") +class AKeyMustServeThePlatform(unittest.TestCase): + """--platform narrowed only a full refresh: under --key it was ignored and + dolphin-sys was refreshed for RomM, which never reads it.""" + + def test_a_key_outside_the_platform_is_refused(self): + import subprocess # noqa: PLC0415 + + root = Path(__file__).resolve().parents[1] + refused = subprocess.run( + [sys.executable, "scripts/refresh_data_dirs.py", "--key", "dolphin-sys", + "--platform", "romm", "--dry-run"], + cwd=root, capture_output=True, text=True, timeout=120, check=False, + ) + self.assertEqual(refused.returncode, 2) + self.assertIn("does not serve romm", refused.stdout + refused.stderr) + + if __name__ == "__main__": unittest.main()