mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-18 09:23:26 -05:00
fix: refuse a platform list where one is taken
generate_pack split --platform on commas to validate it, then used the whole string as one platform and crashed. Every script takes a single platform; a list is refused with a message pointing at --all.
This commit is contained in:
1 parent
1bdfb8d75e
commit
9ba63e6a54
3 files changed
+40
-2
No files matched your search
@@ -424,6 +424,13 @@ def require_platform(name: str, platforms_dir: str = "platforms") -> None:
|
||||
A typo used to end in a traceback (verify, cross_reference) or in "no
|
||||
pack for batocra" after the whole build ran (generate_pack).
|
||||
"""
|
||||
if "," in name:
|
||||
# generate_pack split the list to validate it, then used the whole
|
||||
# string as one name and ended in a traceback.
|
||||
raise SystemExit(
|
||||
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")):
|
||||
return
|
||||
import difflib # noqa: PLC0415
|
||||
|
||||
@@ -2917,8 +2917,7 @@ def _main(held: contextlib.ExitStack) -> None:
|
||||
args = parser.parse_args()
|
||||
packresolve.set_offline(bool(args.offline))
|
||||
if args.platform:
|
||||
for name in args.platform.split(","):
|
||||
require_platform(name.strip(), args.platforms_dir)
|
||||
require_platform(args.platform, args.platforms_dir)
|
||||
|
||||
_refuse_unapplied_flags(args, parser)
|
||||
if args.target:
|
||||
|
||||
@@ -375,6 +375,38 @@ class VerboseAppliesToJson(unittest.TestCase):
|
||||
self.assertNotIn('if d["status"] != Status.OK\n ]', source)
|
||||
|
||||
|
||||
class OnePlatformPerFlag(unittest.TestCase):
|
||||
"""generate_pack validated --platform as a comma list, then used the whole
|
||||
string as one name: `--platform bizhawk,misterfpga` passed and ended in a
|
||||
FileNotFoundError traceback. Every script now says it takes one name."""
|
||||
|
||||
def test_a_list_is_refused_with_a_message(self):
|
||||
import subprocess
|
||||
|
||||
runs = {
|
||||
"generate_pack.py": ["--list-systems"],
|
||||
"verify.py": [],
|
||||
"cross_reference.py": [],
|
||||
}
|
||||
for script, extra in runs.items():
|
||||
with self.subTest(script=script):
|
||||
completed = subprocess.run(
|
||||
[sys.executable, f"scripts/{script}", "--platform",
|
||||
"bizhawk,misterfpga", *extra],
|
||||
capture_output=True, text=True, cwd=ROOT, timeout=600, check=False,
|
||||
)
|
||||
self.assertNotEqual(completed.returncode, 0)
|
||||
self.assertIn("takes one platform", completed.stderr)
|
||||
self.assertNotIn("Traceback", completed.stderr)
|
||||
|
||||
def test_unknown_names_still_get_a_suggestion(self):
|
||||
from common import require_platform
|
||||
|
||||
with self.assertRaises(SystemExit) as caught:
|
||||
require_platform("batocra", str(ROOT / "platforms"))
|
||||
self.assertIn("batocera", str(caught.exception))
|
||||
|
||||
|
||||
class FaqRegressions(unittest.TestCase):
|
||||
"""The FAQ states facts the code owns; these tie it back to the source.
|
||||
|
||||
|
||||
Reference in new issue
Block a user