Selaa lähdekoodia

Deal with Travis-CI's odd color handling

Hamilton Turner 11 vuotta sitten
vanhempi
commit
b63d3be142
1 muutettua tiedostoa jossa 11 lisäystä ja 7 poistoa
  1. 11 7
      toolset/benchmark/benchmarker.py

+ 11 - 7
toolset/benchmark/benchmarker.py

@@ -796,10 +796,14 @@ class Benchmarker:
   def __finish(self):
     if self.mode == "verify":
       tests = self.__gather_tests
-      print Fore.BLUE
-      print header("Verification Summary", top='=', bottom='')
+      # Normally you don't have to use Fore.BLUE before each line, but 
+      # Travis-CI seems to reset color codes on newline (see travis-ci/travis-ci#2692)
+      # or stream flush, so we have to ensure that the color code is printed repeatedly
+      prefix = Fore.CYAN
+      for line in header("Verification Summary", top='=', bottom='').split('\n'):
+        print prefix + line
       for test in tests:
-        print "| Test: %s" % test.name
+        print prefix + "| Test: %s" % test.name
         if test.name in self.results['verify'].keys():
           for test_type, result in self.results['verify'][test.name].iteritems():
             if result.upper() == "PASS":
@@ -808,11 +812,11 @@ class Benchmarker:
               color = Fore.YELLOW
             else:
               color = Fore.RED
-            print "|       " + test_type.ljust(11) + ' : ' + color + result.upper() + Fore.BLUE
+            print prefix + "|       " + test_type.ljust(11) + ' : ' + color + result.upper()
         else:
-          print "|      " + Fore.RED + "NO RESULTS (Did framework launch?)" + Fore.BLUE
-      print header('', top='', bottom='=')
-      print Style.RESET_ALL
+          print prefix + "|      " + Fore.RED + "NO RESULTS (Did framework launch?)"
+          print prefix + "TESTING BLUE IN TRAVIS"
+      print prefix + header('', top='', bottom='=') + Style.RESET_ALL
 
     print "Time to complete: " + str(int(time.time() - self.start_time)) + " seconds"
     print "Results are saved in " + os.path.join(self.result_directory, self.timestamp)