diff --git a/tests/test_progress_dashboard.py b/tests/test_progress_dashboard.py index b5a15e80ce..3821209705 100644 --- a/tests/test_progress_dashboard.py +++ b/tests/test_progress_dashboard.py @@ -517,6 +517,29 @@ def test_paths_outside_the_repository_lose_their_file_name(self): self.assertEqual(pd.scrub("in " + os.path.join(pd.HOME, "work", f"{SENTINEL}.fssm")), "in ") self.assertEqual(pd.scrub(f"C:{sep}work{sep}{SENTINEL}_a.fssm, C:{sep}{SENTINEL}_b.fssm"), " ") + def test_drive_paths_with_spaces_lose_their_whole_name(self): + for line, want in ( + (rf"FAIL: cannot read D:\My work\shaders\{SENTINEL}.fssm", "FAIL: cannot read "), + (rf"D:\My work\a b c\{SENTINEL}.fssm line 3", " line 3"), + (rf"D:\My work\{SENTINEL}_a.fssm, D:\Other work\{SENTINEL}_b.fssm", " "), + (f"FAIL: cannot read D:/My work/shaders/{SENTINEL}.fssm", "FAIL: cannot read "), + (rf"cannot read D:/My work\fixtures\{SENTINEL}.txt", "cannot read "), + (rf"cannot read D:\My work/stubs/{SENTINEL}.spv", "cannot read "), + (rf"D:\My own work/sub dir\a b/{SENTINEL}.fssm line 3", " line 3"), + (rf"D:\My work/{SENTINEL}_a.fssm, D:/Other work\{SENTINEL}_b.fssm", " "), + (rf"Permission denied: 'D:\\My work\\{SENTINEL} one.fssm'", "Permission denied: ''"), + (rf'File "D:\My work\{SENTINEL} one.py", line 3', 'File "", line 3'), + (r"D:\work\a.txt is not a folder", " is not a folder"), + (r"D:\work\a.txt, then tests/test_x.py failed", " then tests/test_x.py failed"), + (r"D:\work\a.txt and tests/test_x.py failed", " and tests/test_x.py failed"), + (r"D:\work\a.txt is 3/4 done", " is 3/4 done"), + ): + with self.subTest(line=line): + self.assertEqual(pd.scrub(line), want) + if os.name == "nt": + sibling = os.path.join(ROOT + " work", f"{SENTINEL} one.fssm") + self.assertEqual(pd.scrub(f"cannot read '{sibling}' now"), "cannot read '' now") + def test_paths_inside_the_repository_become_relative(self): line = "Error: " + os.path.join(ROOT, "tools", "text_tables.py") + " line 3" self.assertEqual(pd.scrub(line), "Error: tools/text_tables.py line 3") diff --git a/tools/progress_dashboard.py b/tools/progress_dashboard.py index 43d3fafdbb..9ef57f9c6a 100644 --- a/tools/progress_dashboard.py +++ b/tools/progress_dashboard.py @@ -145,9 +145,17 @@ def shown(m): checkout = rf"(? 3: line = line.replace(HOME, "~") line = re.sub(r"~[\\/][^\s'\"]*", "", line)