Mercurial > hg
comparison tests/run-tests.py @ 33565:0982d900dccb
run-tests: pass color option via test case object , not global var
At first I updated the color field of the 'options' object (from the
CLI parser), but then I decided to put it directly on the test case
object itself to avoid mutating the shared object (even though all
tests would have the same value).
Differential Revision: https://phab.mercurial-scm.org/D114
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 17 Jul 2017 16:15:15 -0700 |
parents | 2893face0af5 |
children | 97070cbf0813 |
comparison
equal
deleted
inserted
replaced
33564:91e3dcefc9b7 | 33565:0982d900dccb |
---|---|
1562 self._firststarttime = None | 1562 self._firststarttime = None |
1563 # Data stored for the benefit of generating xunit reports. | 1563 # Data stored for the benefit of generating xunit reports. |
1564 self.successes = [] | 1564 self.successes = [] |
1565 self.faildata = {} | 1565 self.faildata = {} |
1566 | 1566 |
1567 global with_color | 1567 if options.color == 'auto': |
1568 if not self.stream.isatty(): # check if the terminal is capable | 1568 self.color = with_color and self.stream.isatty() |
1569 with_color = False | 1569 elif options.color == 'never': |
1570 | 1570 self.color = False |
1571 if options.color != 'auto': | 1571 else: # 'always', for testing purposes |
1572 if options.color == 'never': | 1572 self.color = pygmentspresent |
1573 with_color = False | |
1574 else: # 'always', for testing purposes | |
1575 if pygmentspresent: | |
1576 with_color = True | |
1577 | 1573 |
1578 def addFailure(self, test, reason): | 1574 def addFailure(self, test, reason): |
1579 self.failures.append((test, reason)) | 1575 self.failures.append((test, reason)) |
1580 | 1576 |
1581 if self._options.first: | 1577 if self._options.first: |
1650 raise test.failureException( | 1646 raise test.failureException( |
1651 'server failed to start (HGPORT=%s)' % test._startport) | 1647 'server failed to start (HGPORT=%s)' % test._startport) |
1652 else: | 1648 else: |
1653 self.stream.write('\n') | 1649 self.stream.write('\n') |
1654 for line in lines: | 1650 for line in lines: |
1655 if with_color and pygmentspresent: | 1651 if self.color and pygmentspresent: |
1656 line = pygments.highlight( | 1652 line = pygments.highlight( |
1657 line, | 1653 line, |
1658 lexers.DiffLexer(), | 1654 lexers.DiffLexer(), |
1659 formatters.Terminal256Formatter()) | 1655 formatters.Terminal256Formatter()) |
1660 if PYTHON3: | 1656 if PYTHON3: |