From 7577ec4c18ffe13bfe2ab867ed140cbb1d1f706c Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Mon, 19 Oct 2026 04:30:38 +0200 Subject: [PATCH] fix: count the profiles the named listing shows --- scripts/profile_sync.py | 8 +++++++- tests/test_profile_sync.py | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/scripts/profile_sync.py b/scripts/profile_sync.py index 813f4ece..752ca7c2 100644 --- a/scripts/profile_sync.py +++ b/scripts/profile_sync.py @@ -3304,9 +3304,15 @@ def select_profiles(profiles: dict, args: argparse.Namespace) -> dict: """Profiles matching the selection flags.""" if args.emulator: if args.emulator not in profiles: + # Suggested from what the listing it names shows: counted over the + # alias and test profiles too, "lists all 553" pointed at 530 lines. + listed = sorted( + name for name, profile in profiles.items() + if profile.get("type") not in ("alias", "test") + ) raise SystemExit( f"ERROR: unknown profile {args.emulator}. " - + suggest_names([args.emulator], sorted(profiles), "verify.py --list-emulators") + + suggest_names([args.emulator], listed, "verify.py --list-emulators") ) return {args.emulator: profiles[args.emulator]} diff --git a/tests/test_profile_sync.py b/tests/test_profile_sync.py index cc9828d7..4cc3607f 100644 --- a/tests/test_profile_sync.py +++ b/tests/test_profile_sync.py @@ -4165,5 +4165,25 @@ class TestAnUnansweringRepository(unittest.TestCase): self.assertEqual(report.skipped, "upstream gone (declared): 404 since 2026-10-18") +class TheUnknownProfileHintCountsTheListing(unittest.TestCase): + """profile_sync said "verify.py --list-emulators lists all 553" for a + listing of 530: the alias and test profiles it counted are not listed.""" + + def test_the_count_matches(self): + import subprocess # noqa: PLC0415 + + root = Path(__file__).resolve().parents[1] + hint = subprocess.run( + [sys.executable, "scripts/profile_sync.py", "--emulator", "no-such-profile"], + cwd=root, capture_output=True, text=True, timeout=120, check=False, + ) + listing = subprocess.run( + [sys.executable, "scripts/verify.py", "--list-emulators"], + cwd=root, capture_output=True, text=True, timeout=120, check=False, + ).stdout + count = len([line for line in listing.splitlines() if line.strip()]) + self.assertIn(f"lists all {count}.", hint.stderr + hint.stdout) + + if __name__ == "__main__": unittest.main()