Skip to content

Commit 6007ad7

Browse files
authored
Revert "[llvm-lit] Process ANSI color codes in test output when formatting" (#108104)
Reverts #106776 because of a test failure on Windows.
1 parent 10c04d9 commit 6007ad7

File tree

5 files changed

+2
-54
lines changed

5 files changed

+2
-54
lines changed

llvm/utils/lit/lit/TestRunner.py

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,20 +1017,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
10171017
return exitCode
10181018

10191019

1020-
def findColor(line, curr_color):
1021-
start = line.rfind("\33[")
1022-
if start == -1:
1023-
return curr_color
1024-
end = line.find("m", start+2)
1025-
if end == -1:
1026-
return curr_color
1027-
match = line[start:end+1]
1028-
# "\33[0m" means "reset all formatting". Sometimes the 0 is skipped.
1029-
if match == "\33[m" or match == "\33[0m":
1030-
return None
1031-
return match
1032-
1033-
10341020
def formatOutput(title, data, limit=None):
10351021
if not data.strip():
10361022
return ""
@@ -1041,18 +1027,8 @@ def formatOutput(title, data, limit=None):
10411027
msg = ""
10421028
ndashes = 30
10431029
# fmt: off
1044-
out = f"# .---{title}{'-' * (ndashes - 4 - len(title))}\n"
1045-
curr_color = None
1046-
for line in data.splitlines():
1047-
if curr_color:
1048-
out += "\33[0m"
1049-
out += "# | "
1050-
if curr_color:
1051-
out += curr_color
1052-
out += line + "\n"
1053-
curr_color = findColor(line, curr_color)
1054-
if curr_color:
1055-
out += "\33[0m" # prevent unterminated formatting from leaking
1030+
out = f"# .---{title}{'-' * (ndashes - 4 - len(title))}\n"
1031+
out += f"# | " + "\n# | ".join(data.splitlines()) + "\n"
10561032
out += f"# `---{msg}{'-' * (ndashes - 4 - len(msg))}\n"
10571033
# fmt: on
10581034
return out

llvm/utils/lit/tests/Inputs/escape-color/color-escaped.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

llvm/utils/lit/tests/Inputs/escape-color/color.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

llvm/utils/lit/tests/Inputs/escape-color/lit.cfg

Lines changed: 0 additions & 8 deletions
This file was deleted.

llvm/utils/lit/tests/escape-color.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)