[llvm] [llvm-lit] Process ANSI color codes in test output when formatting (PR #106776)
Alexander Richardson via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 15:14:19 PDT 2024
================
@@ -1005,6 +1005,44 @@ def _executeShCmd(cmd, shenv, results, timeoutHelper):
return exitCode
+def reFindLast(r, s):
+ matches = r.findall(s)
+ if not matches:
+ return None
+ return matches[-1]
+
+
+def findColor(s, curr_color):
+ m = reFindLast(color_re, s)
+ if not m:
+ return curr_color
+ # "\33[0m" means "reset all formatting". Sometimes the 0 is skipped.
+ if m == "\33[m" or m == "\33[0m":
+ return None
+ return m
+
+
+def escapeColor(s, f):
----------------
arichardson wrote:
Also since this is just a single if statement and is called exactly once, I don't think it needs to be separate function.
https://github.com/llvm/llvm-project/pull/106776
More information about the llvm-commits
mailing list