mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 02:27:52 -06:00
fix: fail --manifest-targets without targets dir
This commit is contained in:
1 parent
6721a738b4
commit
dae6b3a146
3 files changed
+35
-13
No files matched your search
@@ -59,9 +59,16 @@ def _run_quick_mode(
|
||||
if holds_other_kind(args.output_dir, "targets"):
|
||||
sys.exit(1)
|
||||
with pack_output_lock(args.output_dir):
|
||||
generate_target_manifests(
|
||||
os.path.join(args.platforms_dir, "targets"), args.output_dir
|
||||
)
|
||||
try:
|
||||
written = generate_target_manifests(
|
||||
os.path.join(args.platforms_dir, "targets"), args.output_dir
|
||||
)
|
||||
except FileNotFoundError as exc:
|
||||
print(exc, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
for name, count in written:
|
||||
print(f" {name}: {count} targets")
|
||||
print(f"Generated {len(written)} target manifest(s) in {args.output_dir}")
|
||||
return True
|
||||
return run_listing(args, parser, args.list)
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from core.artifacts import write_text_atomic
|
||||
@@ -12,23 +11,22 @@ from model.sources import source_yaml_file
|
||||
from model.targets import load_target_config, target_aliases, target_overrides
|
||||
|
||||
|
||||
def generate_target_manifests(targets_dir: str, output_dir: str) -> None:
|
||||
"""Convert target YAMLs to installer JSON manifests."""
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
def generate_target_manifests(targets_dir: str, output_dir: str) -> list[tuple[str, int]]:
|
||||
"""Convert target YAMLs to installer JSON manifests: each platform
|
||||
written, with its number of targets. A missing directory raises."""
|
||||
targets_path = Path(targets_dir)
|
||||
if not targets_path.is_dir():
|
||||
print(f"No targets directory at {targets_dir}", file=sys.stderr)
|
||||
return
|
||||
count = 0
|
||||
raise FileNotFoundError(f"No targets directory at {targets_dir}")
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
written: list[tuple[str, int]] = []
|
||||
for yml_file in sorted(targets_path.glob("*.yml")):
|
||||
if yml_file.name.startswith("_"):
|
||||
continue
|
||||
result = target_list(yml_file)
|
||||
out_path = Path(output_dir) / f"{yml_file.stem}.json"
|
||||
write_text_atomic(out_path, json.dumps(result, indent=2, sort_keys=True) + "\n")
|
||||
count += 1
|
||||
print(f" {yml_file.stem}: {len(result)} targets")
|
||||
print(f"Generated {count} target manifest(s) in {output_dir}")
|
||||
written.append((yml_file.stem, len(result)))
|
||||
return written
|
||||
|
||||
|
||||
def target_list(yml_file: Path) -> dict[str, list[str] | dict | None]:
|
||||
|
||||
@@ -2254,6 +2254,23 @@ class TargetManifestRegressions(unittest.TestCase):
|
||||
with self.assertRaisesRegex(ValueError, "non-empty strings"):
|
||||
generate_target_manifests(str(source), str(output))
|
||||
|
||||
def test_a_missing_targets_directory_fails_the_command(self):
|
||||
"""--manifest-targets printed the missing directory and exited 0
|
||||
with nothing written: the pipeline step read that as done."""
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
with self.assertRaisesRegex(FileNotFoundError, "No targets directory"):
|
||||
generate_target_manifests(str(root / "absent"), str(root / "out"))
|
||||
(root / "plat").mkdir()
|
||||
run = subprocess.run(
|
||||
[sys.executable, str(ROOT / "scripts" / "generate_pack.py"),
|
||||
"--manifest-targets", "--platforms-dir", str(root / "plat"),
|
||||
"--output-dir", str(root / "out")],
|
||||
capture_output=True, text=True, cwd=ROOT, check=False,
|
||||
)
|
||||
self.assertEqual(run.returncode, 1, run.stderr)
|
||||
self.assertIn("No targets directory at", run.stderr)
|
||||
|
||||
|
||||
class CheckoutCompletenessRegressions(unittest.TestCase):
|
||||
"""Coverage is resolved against the disk, so the checkout must be whole.
|
||||
|
||||
Reference in new issue
Block a user