fix: say a platform has no hardware targets

The error named platforms/targets/<name>.yml, which read as a file
missing from the repository (finding 63).
This commit is contained in:
Abdessamad Derraz committed 2026-11-05 11:42:46 +01:00
1 parent f3fe6f58b4
commit 609710e2d7
2 files changed
+27 -4

No files matched your search

+8 -1
View File
@@ -664,8 +664,15 @@ def load_target_config(
targets_dir = os.path.join(platforms_dir, "targets")
target_file = os.path.join(targets_dir, f"{platform_name}.yml")
if not os.path.exists(target_file):
# The expected state for a platform that ships one build, said as
# such: the file path read like a file missing from the repository.
with_targets = sorted(
Path(f).stem for f in os.listdir(targets_dir)
if f.endswith(".yml") and not f.startswith("_")
)
raise FileNotFoundError(
f"No target config for platform '{platform_name}': {target_file}"
f"{platform_name} has no hardware targets: drop --target "
f"(platforms with targets: {', '.join(with_targets)})"
)
with open(target_file) as f:
data = yaml_load(f) or {}
+19 -3
View File
@@ -168,9 +168,6 @@ class HeldButNotPackedNamesEachReason(unittest.TestCase):
"in_pack": False, "omitted": reason, "category": category}
def _printed(self, entries: list[dict]) -> str:
import contextlib # noqa: PLC0415
import io # noqa: PLC0415
out = io.StringIO()
with contextlib.redirect_stdout(out):
verify._print_undeclared_section({"undeclared_files": entries}, False)
@@ -219,6 +216,25 @@ class HeldButNotPackedNamesEachReason(unittest.TestCase):
self.assertIn("Core files held but not packed: 2 (installed with its emulator)", text)
class APlatformWithoutTargetsSaysSo(unittest.TestCase):
"""`--platform misterfpga --target switch` printed 'No target config for
platform 'misterfpga': platforms/targets/misterfpga.yml', which reads as
a file missing from the repository."""
def test_the_message_names_the_reason_and_the_platforms_with_targets(self):
with tempfile.TemporaryDirectory() as tmp:
(Path(tmp) / "targets").mkdir()
for name in ("retroarch", "batocera", "_overrides"):
(Path(tmp) / "targets" / f"{name}.yml").write_text("targets: {}\n")
with self.assertRaises(FileNotFoundError) as caught:
common.load_target_config("misterfpga", "switch", tmp)
self.assertEqual(
str(caught.exception),
"misterfpga has no hardware targets: drop --target "
"(platforms with targets: batocera, retroarch)",
)
class OneSpellingPerOption(unittest.TestCase):
"""verify.py -p batocera worked and slots.py -p batocera was refused."""