diff --git a/scripts/generate_pack.py b/scripts/generate_pack.py index d94a2975d..3934830a9 100644 --- a/scripts/generate_pack.py +++ b/scripts/generate_pack.py @@ -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 diff --git a/scripts/verify.py b/scripts/verify.py index 27149e23e..d40377424 100644 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -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) diff --git a/tests/test_tool_messages.py b/tests/test_tool_messages.py index c2e59f6e9..91439fc91 100644 --- a/tests/test_tool_messages.py +++ b/tests/test_tool_messages.py @@ -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."""