mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: return target skip notes, print them in scope
build_target_cores_cache printed its INFO notes itself, so expected_pack_names wrote notes about platforms nobody asked for. The notes come back with the cache and target_scope, the command-line wrapper, prints them.
This commit is contained in:
1 parent
57ee0cdd8f
commit
8787f453c7
5 files changed
+29
-21
No files matched your search
@@ -248,10 +248,11 @@ def build_target_cores_cache(
|
||||
target: str,
|
||||
platforms_dir: str,
|
||||
is_all: bool = False,
|
||||
) -> tuple[dict[str, set[str] | None], list[str]]:
|
||||
) -> tuple[dict[str, set[str] | None], list[str], list[str]]:
|
||||
"""Build target cores cache for a list of platforms.
|
||||
|
||||
Returns (cache dict, list of platforms to keep after skipping failures).
|
||||
Returns (cache dict, platforms kept after skipping failures, one note per
|
||||
skipped platform for a command line to print).
|
||||
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
|
||||
@@ -282,10 +283,7 @@ def build_target_cores_cache(
|
||||
# The seventeen per-platform lines buried the one suggestion that
|
||||
# mattered: the refusal names the closest target across them all.
|
||||
raise ValueError(_unknown_target_message(target, platforms, platforms_dir))
|
||||
# On stderr: slots --json printed them ahead of its document.
|
||||
for note in notes:
|
||||
print(note, file=sys.stderr)
|
||||
return cache, kept
|
||||
return cache, kept, notes
|
||||
|
||||
|
||||
def target_scope(
|
||||
@@ -299,10 +297,16 @@ def target_scope(
|
||||
if not target:
|
||||
return {}, platforms
|
||||
try:
|
||||
return build_target_cores_cache(platforms, target, platforms_dir, is_all=is_all)
|
||||
cache, kept, notes = build_target_cores_cache(
|
||||
platforms, target, platforms_dir, is_all=is_all
|
||||
)
|
||||
except (FileNotFoundError, ValueError) as exc:
|
||||
print(f"ERROR: {exc}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
# On stderr: slots --json printed them ahead of its document.
|
||||
for note in notes:
|
||||
print(note, file=sys.stderr)
|
||||
return cache, kept
|
||||
|
||||
|
||||
def _unknown_target_message(target: str, platforms: list[str], platforms_dir: str) -> str:
|
||||
|
||||
@@ -242,7 +242,7 @@ def expected_pack_names(
|
||||
cache = None
|
||||
if target_name:
|
||||
try:
|
||||
cache, pool = build_target_cores_cache(
|
||||
cache, pool, _notes = build_target_cores_cache(
|
||||
pool, target_name, platforms_dir, is_all=True
|
||||
)
|
||||
except ValueError:
|
||||
|
||||
@@ -6957,12 +6957,11 @@ class AnUnknownTargetIsRefusedUnderAll(unittest.TestCase):
|
||||
from scripts.model.registry import 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
|
||||
)
|
||||
with self.assertRaises(ValueError):
|
||||
build_target_cores_cache(platforms, "swtich", str(ROOT / "platforms"), is_all=True)
|
||||
_cache, kept, _notes = build_target_cores_cache(
|
||||
platforms, "switch", str(ROOT / "platforms"), is_all=True
|
||||
)
|
||||
self.assertNotIn("bizhawk", kept)
|
||||
self.assertIn("retroarch", kept)
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@ class CheckReadsTheTargetLikeTheBuild(unittest.TestCase):
|
||||
def test_a_platform_without_a_target_file(self):
|
||||
# Left out of a targeted --all run rather than built unfiltered, and
|
||||
# a run where no platform has the target is refused.
|
||||
with tempfile.TemporaryDirectory() as platforms, \
|
||||
contextlib.redirect_stdout(io.StringIO()), self.assertRaises(ValueError):
|
||||
with tempfile.TemporaryDirectory() as platforms, self.assertRaises(ValueError):
|
||||
build_target_cores_cache(["recalbox"], "x86_64", platforms, is_all=True)
|
||||
# The build never packs such a platform under the target, so the
|
||||
# check refuses it too instead of reading the full pack.
|
||||
@@ -262,9 +261,9 @@ class CrossReferenceReadsTheTargetAcrossPlatforms(unittest.TestCase):
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / "emulators"))
|
||||
with contextlib.redirect_stderr(io.StringIO()):
|
||||
tree = tree_scope(None, "switch", platforms_dir, profiles)
|
||||
cache, kept = build_target_cores_cache(
|
||||
list_registered_platforms(platforms_dir), "switch", platforms_dir, is_all=True,
|
||||
)
|
||||
cache, kept, _notes = build_target_cores_cache(
|
||||
list_registered_platforms(platforms_dir), "switch", platforms_dir, is_all=True,
|
||||
)
|
||||
self.assertEqual(tree.selected, kept)
|
||||
self.assertIsNone(tree.platform)
|
||||
expected: set[str] = set()
|
||||
|
||||
@@ -19,7 +19,7 @@ from core.cli import SourceUnreadable
|
||||
from core.github import github_token, _gh_cli_token
|
||||
from model.profiles import select_emulator_profiles, ProfileSelectionError
|
||||
from model.registry import list_registered_platforms
|
||||
from model.targets import load_target_config, build_target_cores_cache
|
||||
from model.targets import load_target_config, build_target_cores_cache, target_scope
|
||||
from exporter import diffreport
|
||||
import pipeline
|
||||
from orchestrate import guards, labels, prepare, runner
|
||||
@@ -312,7 +312,13 @@ class AMistypedTargetEndsEveryToolAlike(unittest.TestCase):
|
||||
platforms = list_registered_platforms(str(REPO_ROOT / "platforms"))
|
||||
out, err = io.StringIO(), io.StringIO()
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
build_target_cores_cache(platforms, "switch", str(REPO_ROOT / "platforms"), is_all=True)
|
||||
_cache, _kept, notes = build_target_cores_cache(
|
||||
platforms, "switch", str(REPO_ROOT / "platforms"), is_all=True
|
||||
)
|
||||
self.assertEqual(out.getvalue() + err.getvalue(), "")
|
||||
self.assertTrue(any(n.startswith("INFO: Skipping") for n in notes))
|
||||
with contextlib.redirect_stdout(out), contextlib.redirect_stderr(err):
|
||||
target_scope(platforms, "switch", str(REPO_ROOT / "platforms"), is_all=True)
|
||||
self.assertEqual(out.getvalue(), "")
|
||||
self.assertIn("INFO: Skipping", err.getvalue())
|
||||
|
||||
|
||||
Reference in new issue
Block a user