Mercurial > hg-stable
changeset 33561:2893face0af5
run-tests: check if stream is a tty before using color
Previous implementation (e80041832eec) checked only if sys.stderr was a tty
which was less general. Also makes sure that colors is never used if pygments is
not available, irrespective of --color flag value.
author | Matthieu Laneuville <matthieu.laneuville@octobus.net> |
---|---|
date | Tue, 18 Jul 2017 07:19:26 +0900 |
parents | d4df141f90d1 |
children | 3cfabb6cfd51 |
files | tests/run-tests.py |
diffstat | 1 files changed, 11 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Fri Jul 14 21:44:29 2017 -0700 +++ b/tests/run-tests.py Tue Jul 18 07:19:26 2017 +0900 @@ -101,9 +101,6 @@ except ImportError: pass -if not sys.stderr.isatty(): # check if the terminal is capable - with_color = False - if sys.version_info > (3, 5, 0): PYTHON3 = True xrange = range # we use xrange in one place, and we'd rather not use range @@ -416,13 +413,6 @@ parser.error('--chg does not work when --with-hg is specified ' '(use --with-chg instead)') - global with_color - if options.color != 'auto': - if options.color == 'never': - with_color = False - else: # 'always', for testing purposes - with_color = True - global useipv6 if options.ipv6: useipv6 = checksocketfamily('AF_INET6') @@ -1574,6 +1564,17 @@ 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 + def addFailure(self, test, reason): self.failures.append((test, reason))