diff --git a/scripts/common.py b/scripts/common.py index 1518f387..41df23f8 100644 --- a/scripts/common.py +++ b/scripts/common.py @@ -2501,7 +2501,10 @@ def list_emulator_profiles(emulators_dir: str, skip_aliases: bool = True) -> Non ptype = p.get("type", "libretro") systems = ", ".join(p.get("systems", [])[:3]) more = "..." if len(p.get("systems", [])) > 3 else "" - print(f" {name:30s} {display:40s} [{ptype}] {systems}{more}") + # The type is padded to its longest value, so the systems start in + # one column whatever the type reads. + kind = f"[{ptype}]" + print(f" {name:30s} {display:40s} {kind:24s}{systems}{more}".rstrip()) def system_index(profiles: dict) -> dict[str, tuple[str, set[str]]]: @@ -2537,9 +2540,8 @@ def list_platform_system_ids(platform_name: str, platforms_dir: str) -> None: file_count = len(systems[sys_id].get("files", [])) mfr = systems[sys_id].get("manufacturer", "") mfr_display = f" [{mfr.split('|')[0]}]" if mfr else "" - print( - f" {sys_id:35s} ({file_count} file{'s' if file_count != 1 else ''}){mfr_display}" - ) + count = f"({file_count} file{'s' if file_count != 1 else ''})" + print(f" {sys_id:35s} {count:12s}{mfr_display}".rstrip()) def build_target_cores_cache( diff --git a/tests/test_system_selection.py b/tests/test_system_selection.py index 889bec18..5c09325b 100644 --- a/tests/test_system_selection.py +++ b/tests/test_system_selection.py @@ -423,5 +423,27 @@ class ASystemPackHoldsThatSystem(unittest.TestCase): self.assertEqual(report["total_files"], 2) +class ListingsKeepTheirColumns(unittest.TestCase): + """--list-systems and --list-emulators started their last column at a + position that moved with the file count and the profile type.""" + + def test_the_last_column_starts_in_one_place(self): + listing = subprocess.run( + [sys.executable, "scripts/generate_pack.py", "--platform", "retroarch", + "--list-systems"], cwd=REPO_ROOT, capture_output=True, text=True, timeout=300, + ).stdout.splitlines() + starts = {line.index("[") for line in listing if "[" in line} + self.assertEqual(len(starts), 1, listing[:5]) + emulators = subprocess.run( + [sys.executable, "scripts/verify.py", "--list-emulators"], + cwd=REPO_ROOT, capture_output=True, text=True, timeout=300, + ).stdout.splitlines() + ends = {line.index("]") + 1 for line in emulators if "]" in line} + tails = {len(line) - len(line[line.index("]") + 1:].lstrip()) + for line in emulators if "]" in line and line[line.index("]") + 1:].strip()} + self.assertEqual(len(tails), 1, sorted(ends)) + self.assertFalse([line for line in listing + emulators if line != line.rstrip()]) + + if __name__ == "__main__": unittest.main()