fix: count listed systems in the --system hint

A mistyped --system said '--list-systems lists all 579' and the listing
prints 532: the hint counted every spelling across profiles, and
system_index merges the ones that differ in case or separator before
printing. Both verify.py and generate_pack.py now pass that count to
suggest_names, whose listed parameter exists for this case.
This commit is contained in:
Abdessamad Derraz committed 2026-11-06 14:55:40 +01:00
1 parent c9e5ea67e7
commit de8f20f409
3 files changed
+34 -2

No files matched your search

+5 -1
View File
@@ -43,6 +43,7 @@ from common import (
require_directory,
target_listing_line,
suggest_names,
system_index,
require_platform,
load_target_config,
archive_entry,
@@ -2059,7 +2060,10 @@ def generate_system_pack(
f"No emulators found for system(s): {', '.join(system_ids)}",
file=sys.stderr,
)
print(suggest_names(system_ids, sorted(all_systems), "--list-systems"),
# --list-systems merges spellings that differ in case or separator:
# the hint counted 579 spellings for the 532 lines it prints.
print(suggest_names(system_ids, sorted(all_systems), "--list-systems",
listed=len(system_index(profiles))),
file=sys.stderr)
return None
+5 -1
View File
@@ -43,6 +43,7 @@ from common import (
platform_arg,
target_listing_line,
suggest_names,
system_index,
require_platform,
archive_entry,
archive_is_optional,
@@ -2611,7 +2612,10 @@ def verify_system(
f"No emulators found for system(s): {', '.join(system_ids)}",
file=sys.stderr,
)
print(suggest_names(system_ids, sorted(all_systems), "--list-systems"),
# --list-systems merges spellings that differ in case or separator:
# the hint counted 579 spellings for the 532 lines it prints.
print(suggest_names(system_ids, sorted(all_systems), "--list-systems",
listed=len(system_index(profiles))),
file=sys.stderr)
sys.exit(1)
+24
View File
@@ -85,6 +85,30 @@ class AMistypedTargetGetsTheClosestName(unittest.TestCase):
class TheSystemHintCountsTheListing(unittest.TestCase):
"""`--system sony-playstaton` said "--list-systems lists all 579" and
--list-systems printed 532: the hint counted spellings, the listing
merges the ones that differ in case or separator."""
def test_both_tools_count_the_lines_the_listing_prints(self):
listing = subprocess.run(
[sys.executable, "scripts/verify.py", "--list-systems"],
cwd=REPO_ROOT, capture_output=True, text=True, timeout=300, check=True,
)
printed = sum(1 for line in listing.stdout.splitlines() if "emulator" in line)
for script in ("verify.py", "generate_pack.py"):
with self.subTest(script=script), tempfile.TemporaryDirectory() as out:
argv = [sys.executable, f"scripts/{script}", "--system", "sony-playstaton"]
if script == "generate_pack.py":
argv += ["--output-dir", out]
proc = subprocess.run(
argv, cwd=REPO_ROOT, capture_output=True, text=True, timeout=300,
check=False,
)
self.assertEqual(proc.returncode, 1, proc.stderr)
self.assertIn(f"--list-systems lists all {printed}.", proc.stderr)
class AMistypedTargetAcrossAllPlatforms(unittest.TestCase):
"""`verify --all --target swich` ended on "no platform has it" after 17
INFO lines, two of which held the suggestion."""