fix: refuse a target no platform has

With --all, an unknown --target skipped every platform that has targets and ran the others (BizHawk, MiSTer) unfiltered, so verify, slots and the pipeline exited 0 on a typo. A platform without targets is now left out like the rest, and a target no platform has is refused.
This commit is contained in:
Abdessamad Derraz committed 2026-10-20 03:27:41 +02:00
1 parent c7c2f260f3
commit 7edd438af1
3 files changed
+38 -10

No files matched your search

+9 -3
View File
@@ -2609,6 +2609,10 @@ def build_target_cores_cache(
"""Build target cores cache for a list of platforms.
Returns (cache dict, list of platforms to keep after skipping failures).
A platform without a targets file cannot honour the target and is left
out with the others, never run unfiltered, and a target no platform knows
is refused: `--all --target swtich` checked BizHawk and MiSTer whole and
exited 0, a green run that said nothing about the Switch.
"""
cache: dict[str, set[str] | None] = {}
skip: list[str] = []
@@ -2616,10 +2620,10 @@ def build_target_cores_cache(
try:
cache[p] = load_target_config(p, target, platforms_dir)
except FileNotFoundError:
if is_all:
cache[p] = None
else:
if not is_all:
raise
print(f"INFO: Skipping {p}: no hardware targets")
skip.append(p)
except ValueError as e:
if is_all:
print(f"INFO: Skipping {p}: {e}")
@@ -2627,6 +2631,8 @@ def build_target_cores_cache(
else:
raise
kept = [p for p in platforms if p not in skip]
if is_all and platforms and not kept:
raise ValueError(f"unknown target '{target}': no platform has it")
return cache, kept
+11 -7
View File
@@ -4442,10 +4442,10 @@ def _target_cores_for(
"""
if not target_name:
return None
cache, _kept = build_target_cores_cache(
[platform_name], target_name, platforms_dir, is_all=True
)
return cache.get(platform_name)
try:
return load_target_config(platform_name, target_name, platforms_dir)
except (FileNotFoundError, ValueError):
return None
def _expected_pack_names(
@@ -4479,9 +4479,13 @@ def _expected_pack_names(
)
cache = None
if target_name:
cache, pool = build_target_cores_cache(
pool, target_name, platforms_dir, is_all=True
)
try:
cache, pool = build_target_cores_cache(
pool, target_name, platforms_dir, is_all=True
)
except ValueError:
# No platform has the target: no pack was built under it.
continue
for group, representative in group_identical_platforms(
pool, platforms_dir, cache
):
+18
View File
@@ -5438,5 +5438,23 @@ class AForcedRehashIsCheckedAgainstTheLastOne(unittest.TestCase):
)
class AnUnknownTargetIsRefusedUnderAll(unittest.TestCase):
"""--all --target swtich skipped every platform with targets and checked
BizHawk and MiSTer unfiltered: a green run about no Switch at all."""
def test_a_typo_is_refused_and_targetless_platforms_are_left_out(self):
from scripts.common import build_target_cores_cache, list_registered_platforms
platforms = list_registered_platforms(str(ROOT / "platforms"))
with contextlib.redirect_stdout(io.StringIO()):
with self.assertRaises(ValueError):
build_target_cores_cache(platforms, "swtich", str(ROOT / "platforms"), is_all=True)
_cache, kept = build_target_cores_cache(
platforms, "switch", str(ROOT / "platforms"), is_all=True
)
self.assertNotIn("bizhawk", kept)
self.assertIn("retroarch", kept)
if __name__ == "__main__":
unittest.main()