Skip to content

Revert "[llvm-lit] Process ANSI color codes in test output when formatting" #108104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading