D114: run-tests: pass color option via test case object , not global var

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Jul 18 15:27:05 EDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG81dbaa1c053b: run-tests: pass color option via test case object , not global var (authored by martinvonz).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D114?vs=257&id=283

REVISION DETAIL
  https://phab.mercurial-scm.org/D114

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1564,16 +1564,12 @@
         self.successes = []
         self.faildata = {}
 
-        global with_color
-        if not self.stream.isatty(): # check if the terminal is capable
-            with_color = False
-
-        if options.color != 'auto':
-            if options.color == 'never':
-                with_color = False
-            else: # 'always', for testing purposes
-                if pygmentspresent:
-                    with_color = True
+        if options.color == 'auto':
+            self.color = with_color and self.stream.isatty()
+        elif options.color == 'never':
+            self.color = False
+        else: # 'always', for testing purposes
+            self.color = pygmentspresent
 
     def addFailure(self, test, reason):
         self.failures.append((test, reason))
@@ -1652,7 +1648,7 @@
                 else:
                     self.stream.write('\n')
                     for line in lines:
-                        if with_color and pygmentspresent:
+                        if self.color and pygmentspresent:
                             line = pygments.highlight(
                                     line,
                                     lexers.DiffLexer(),



EMAIL PREFERENCES
  https://phab.mercurial-scm.org/settings/panel/emailpreferences/

To: martinvonz, #hg-reviewers, krbullock
Cc: krbullock, mercurial-devel


More information about the Mercurial-devel mailing list