fix: accept only registered platforms

require_platform checks the registry instead of any platforms/<name>.yml:
verify --platform _shared reported 0/0 present and exited 0. --all and
--platform resolve through model.cliargs.selected_platforms in auto_fetch,
generate_truth, diff_truth, export_native and verify. The truth directory
is core.paths.TRUTH_DIR for its writer and its three readers, and the
remaining literal database and profile paths read core.paths and
add_repo_inputs.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 06:04:31 +01:00
1 parent a732e69251
commit ed19ae4198
15 files changed
+69 -67

No files matched your search

+24 -3
View File
@@ -63,7 +63,9 @@ def platform_arg(value: str) -> str:
def require_platform(name: str, platforms_dir: str = PLATFORMS_DIR) -> None:
"""Exit with a usable message when no platform answers to a name.
"""Exit with a usable message when no registered platform answers to a
name. A file under platforms/ is not enough: _shared, _registry and the
emulatorjs base config passed and reported 0/0 present.
A typo used to end in a traceback (verify, cross_reference) or in "no
pack for batocra" after the whole build ran (generate_pack).
@@ -75,11 +77,16 @@ def require_platform(name: str, platforms_dir: str = PLATFORMS_DIR) -> None:
f"ERROR: --platform takes one platform, not '{name}'. "
"Run once per platform, or use --all."
)
if os.path.exists(os.path.join(platforms_dir, f"{name}.yml")):
if not os.path.exists(os.path.join(platforms_dir, "_registry.yml")):
# A fixture directory without a registry names its platforms by file.
if os.path.exists(os.path.join(platforms_dir, f"{name}.yml")):
return
raise SystemExit(f"ERROR: unknown platform '{name}' in {platforms_dir}")
known = list_registered_platforms(platforms_dir)
if name in known:
return
import difflib
known = list_registered_platforms(platforms_dir)
close = difflib.get_close_matches(name, known, n=1)
hint = f" Close match: '{close[0]}'." if close else ""
raise SystemExit(
@@ -87,6 +94,20 @@ def require_platform(name: str, platforms_dir: str = PLATFORMS_DIR) -> None:
)
def selected_platforms(
args: argparse.Namespace, parser: argparse.ArgumentParser | None = None
) -> list[str]:
"""The platforms --all or --platform names, every one registered."""
if args.all:
return list_registered_platforms(args.platforms_dir)
if args.platform:
require_platform(args.platform, args.platforms_dir)
return [args.platform]
if parser is not None:
parser.error("Specify --platform or --all")
raise SystemExit("ERROR: specify --platform or --all")
def list_emulator_profiles(emulators_dir: str, skip_aliases: bool = True) -> None:
"""Print available emulator profiles."""
profiles = load_emulator_profiles(emulators_dir, skip_aliases=False)