fix: one-line errors for --record-coreinfo

This commit is contained in:
Abdessamad Derraz committed 2026-11-06 14:45:26 +01:00
1 parent 3b137cd266
commit 395910ed2b
2 files changed
+27 -4

No files matched your search

+10 -2
View File
@@ -54,11 +54,13 @@ import pin_installer # noqa: E402
import refresh_data_dirs # noqa: E402
import upstream # noqa: E402
from common import ( # noqa: E402
InputMissing,
apply_target_overrides,
list_registered_platforms,
load_emulator_profiles,
load_platform_registry,
require_directory,
suggest_names,
upstream_profile_index,
write_text_atomic,
yaml_load,
@@ -893,7 +895,10 @@ def record_core_info(
"""
unknown = sorted(set(names) - set(blobs))
if unknown:
raise ValueError(f"no such .info in core-info: {', '.join(unknown)}")
raise InputMissing(
f"no such .info in core-info: {', '.join(unknown)}. "
+ suggest_names(unknown, list(blobs), "libretro-core-info")
)
recorded = load_core_info_record(path) or {}
recorded.update({n: blobs[n] for n in (names or blobs)})
payload = {"repository": CORE_INFO_REPO, "blobs": dict(sorted(recorded.items()))}
@@ -1839,7 +1844,10 @@ def main() -> int:
if args.record_coreinfo is not None:
blobs = core_info_blobs(args.cache_dir, args.offline)
if not blobs:
raise RuntimeError("core-info listing unavailable: nothing recorded")
raise InputMissing(
f"core-info listing not in {args.cache_dir}: run without --offline"
if args.offline else "core-info listing unavailable: the GitHub API did not answer"
)
done = record_core_info(blobs, args.record_coreinfo)
print(f"recorded {len(done)} .info file(s) as reviewed")
return 0
+17 -2
View File
@@ -316,8 +316,23 @@ class CoreResolutionTests(unittest.TestCase):
record.write_text(cf.json.dumps({"blobs": {"a": "1", "b": "1"}}))
cf.record_core_info({"a": "2", "b": "2"}, ["a"], record)
self.assertEqual(cf.load_core_info_record(record), {"a": "2", "b": "1"})
with self.assertRaises(ValueError):
cf.record_core_info({"a": "2"}, ["ghost"], record)
with self.assertRaises(cf.InputMissing) as raised:
cf.record_core_info({"a": "2", "ghosts": "1"}, ["ghost"], record)
self.assertIn("Did you mean: ghosts?", str(raised.exception))
def test_record_errors_are_one_line(self):
"""A mistyped core and an empty offline cache ended on a traceback."""
import subprocess # noqa: PLC0415
with tempfile.TemporaryDirectory() as tmp:
proc = subprocess.run(
[sys.executable, str(REPO_ROOT / "scripts" / "check_freshness.py"), "--offline",
"--cache-dir", tmp, "--record-coreinfo"],
capture_output=True, text=True, check=False, timeout=120,
)
self.assertEqual(proc.returncode, 1)
self.assertNotIn("Traceback", proc.stderr)
self.assertIn("run without --offline", proc.stderr)
def test_offline_without_a_cached_listing_is_skipped(self):
"""Offline, the row read UNKNOWN and failed the run as an upstream