[lit] Change progress bar color to red on first failure
authorJulian Lettner <julian.lettner@gmail.com>
Mon, 25 Feb 2019 06:38:44 +0000 (22:38 -0800)
committerJulian Lettner <julian.lettner@apple.com>
Wed, 30 Oct 2019 22:09:43 +0000 (15:09 -0700)
llvm/utils/lit/lit/ProgressBar.py
llvm/utils/lit/lit/display.py

index cfe6d70..57b354e 100644 (file)
@@ -218,7 +218,7 @@ class ProgressBar:
     The progress bar is colored, if the terminal supports color
     output; and adjusts to the width of the terminal.
     """
-    BAR = '%s${GREEN}[${BOLD}%s%s${NORMAL}${GREEN}]${NORMAL}%s'
+    BAR = '%s${%s}[${BOLD}%s%s${NORMAL}${%s}]${NORMAL}%s'
     HEADER = '${BOLD}${CYAN}%s${NORMAL}\n\n'
         
     def __init__(self, term, header, useETA=True):
@@ -235,7 +235,7 @@ class ProgressBar:
                 self.XNL = "" # Cursor must be fed to the next line
         else:
             self.width = 75
-        self.bar = term.render(self.BAR)
+        self.barColor = 'GREEN'
         self.header = self.term.render(self.HEADER % header.center(self.width))
         self.cleared = 1 #: true if we haven't drawn the bar yet.
         self.useETA = useETA
@@ -264,9 +264,12 @@ class ProgressBar:
             message = message + ' '*(self.width - len(message))
         else:
             message = '... ' + message[-(self.width-4):]
+        bc = self.barColor
+        bar = self.BAR % (prefix, bc, '='*n, '-'*(barWidth-n), bc, suffix)
+        bar = self.term.render(bar)
         sys.stdout.write(
             self.BOL + self.term.UP + self.term.CLEAR_EOL +
-            (self.bar % (prefix, '='*n, '-'*(barWidth-n), suffix)) +
+            bar +
             self.XNL +
             self.term.CLEAR_EOL + message)
         if not self.term.XN:
index 8a3857c..5d8bee1 100644 (file)
@@ -52,6 +52,8 @@ class ProgressDisplay(object):
             self.print_result(test)
 
         if self.progressBar:
+            if test.isFailure():
+                self.progressBar.barColor = 'RED'
             percent = float(self.completed) / self.numTests
             self.progressBar.update(percent, test.getFullName())