mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-06 10:03:49 -06:00
fix: generate_truth refuses a target it lacks
--platform bizhawk --target switch printed skipped, then Done., and exited 0 with no model written. generate_truth now resolves targets through build_target_cores_cache, as verify and generate_pack do: a named platform without the target is refused with exit 1, --all leaves such platforms out and says so.
This commit is contained in:
1 parent
25b9c85208
commit
dfa1cc31d3
2 files changed
+31
-12
No files matched your search
+15
-12
@@ -14,13 +14,13 @@ import sys
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from common import (
|
||||
build_target_cores_cache,
|
||||
platform_arg,
|
||||
list_registered_platforms,
|
||||
load_data_dir_registry,
|
||||
load_database,
|
||||
load_emulator_profiles,
|
||||
load_platform_config,
|
||||
load_target_config,
|
||||
require_directory,
|
||||
require_platform,
|
||||
require_yaml,
|
||||
@@ -97,6 +97,19 @@ def main(argv: list[str] | None = None) -> None:
|
||||
require_platform(args.platform, args.platforms_dir)
|
||||
platforms = [args.platform]
|
||||
|
||||
# A named platform without that target is refused, as verify and
|
||||
# generate_pack refuse it: skipped, it printed Done. and exited 0 with
|
||||
# no model written. --all leaves such platforms out and says so.
|
||||
target_cores_cache: dict[str, set[str] | None] = {}
|
||||
if args.target:
|
||||
try:
|
||||
target_cores_cache, platforms = build_target_cores_cache(
|
||||
platforms, args.target, args.platforms_dir, is_all=args.all
|
||||
)
|
||||
except (FileNotFoundError, ValueError) as exc:
|
||||
print(f"ERROR: {exc}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# A target-narrowed model is a different artifact: written under the
|
||||
# platform's own name it overwrote the full one, and diff_truth then
|
||||
# compared a narrowed model against the whole scrape. Its directory is
|
||||
@@ -109,17 +122,7 @@ def main(argv: list[str] | None = None) -> None:
|
||||
output_dir, [name], args.target, args.platforms_dir
|
||||
)
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
target_cores: set[str] | None = None
|
||||
if args.target:
|
||||
try:
|
||||
target_cores = load_target_config(
|
||||
name,
|
||||
args.target,
|
||||
args.platforms_dir,
|
||||
)
|
||||
except FileNotFoundError:
|
||||
print(f" {name}: no target config, skipped")
|
||||
continue
|
||||
target_cores = target_cores_cache.get(name)
|
||||
|
||||
# Load platform config (with inheritance) and registry entry
|
||||
try:
|
||||
|
||||
@@ -60,6 +60,22 @@ class ATargetedModelIsItsOwnArtifact(unittest.TestCase):
|
||||
)
|
||||
|
||||
|
||||
def test_a_named_platform_without_the_target_is_refused(self):
|
||||
"""bizhawk --target switch printed "skipped", then Done., exit 0,
|
||||
and wrote no model: the diff after it failed instead."""
|
||||
repo = pathlib.Path(__file__).resolve().parent.parent
|
||||
with tempfile.TemporaryDirectory(dir=str(repo / "tmp")) as directory:
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "scripts/generate_truth.py", "--platform", "bizhawk",
|
||||
"--target", "switch", "--output-dir", directory],
|
||||
capture_output=True, check=False, text=True, cwd=str(repo), timeout=400,
|
||||
)
|
||||
self.assertEqual(proc.returncode, 1, proc.stdout + proc.stderr)
|
||||
self.assertIn("bizhawk has no hardware targets", proc.stderr)
|
||||
self.assertNotIn("Done.", proc.stdout)
|
||||
self.assertEqual(list(pathlib.Path(directory).iterdir()), [])
|
||||
|
||||
|
||||
class ADiffThatComparedNothingFails(unittest.TestCase):
|
||||
"""diff_truth --all skipped every platform without a model and exited 0."""
|
||||
|
||||
|
||||
Reference in new issue
Block a user