Skip to content

Commit

Permalink
Revert "[llvm-lit] Process ANSI color codes in test output when forma…
Browse files Browse the repository at this point in the history
…tting" (llvm#108104)

Reverts llvm#106776 because of a test failure on Windows.
  • Loading branch information
hnrklssn authored Sep 10, 2024
1 parent 10c04d9 commit 6007ad7
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 54 deletions.
28 changes: 2 additions & 26 deletions llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1017,20 +1017,6 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
return exitCode


def findColor(line, curr_color):
start = line.rfind("\33[")
if start == -1:
return curr_color
end = line.find("m", start+2)
if end == -1:
return curr_color
match = line[start:end+1]
# "\33[0m" means "reset all formatting". Sometimes the 0 is skipped.
if match == "\33[m" or match == "\33[0m":
return None
return match


def formatOutput(title, data, limit=None):
if not data.strip():
return ""
Expand All @@ -1041,18 +1027,8 @@ def formatOutput(title, data, limit=None):
msg = ""
ndashes = 30
# fmt: off
out = f"# .---{title}{'-' * (ndashes - 4 - len(title))}\n"
curr_color = None
for line in data.splitlines():
if curr_color:
out += "\33[0m"
out += "# | "
if curr_color:
out += curr_color
out += line + "\n"
curr_color = findColor(line, curr_color)
if curr_color:
out += "\33[0m" # prevent unterminated formatting from leaking
out = f"# .---{title}{'-' * (ndashes - 4 - len(title))}\n"
out += f"# | " + "\n# | ".join(data.splitlines()) + "\n"
out += f"# `---{msg}{'-' * (ndashes - 4 - len(msg))}\n"
# fmt: on
return out
Expand Down
10 changes: 0 additions & 10 deletions llvm/utils/lit/tests/Inputs/escape-color/color-escaped.txt

This file was deleted.

6 changes: 0 additions & 6 deletions llvm/utils/lit/tests/Inputs/escape-color/color.txt

This file was deleted.

8 changes: 0 additions & 8 deletions llvm/utils/lit/tests/Inputs/escape-color/lit.cfg

This file was deleted.

4 changes: 0 additions & 4 deletions llvm/utils/lit/tests/escape-color.py

This file was deleted.

0 comments on commit 6007ad7

Please sign in to comment.