tests/run-tests.py
changeset 33552 754569f5e999
parent 33500 9c6e64911de0
child 33561 2893face0af5
equal deleted inserted replaced
33551:1d1779734c99 33552:754569f5e999
    87 origenviron = os.environ.copy()
    87 origenviron = os.environ.copy()
    88 osenvironb = getattr(os, 'environb', os.environ)
    88 osenvironb = getattr(os, 'environb', os.environ)
    89 processlock = threading.Lock()
    89 processlock = threading.Lock()
    90 
    90 
    91 with_color = False
    91 with_color = False
    92 
    92 pygmentspresent = False
    93 # ANSI color is unsupported prior to Windows 10
    93 # ANSI color is unsupported prior to Windows 10
    94 if os.name != 'nt':
    94 if os.name != 'nt':
    95     try: # is pygments installed
    95     try: # is pygments installed
    96         import pygments
    96         import pygments
    97         import pygments.lexers as lexers
    97         import pygments.lexers as lexers
    98         import pygments.formatters as formatters
    98         import pygments.formatters as formatters
    99         with_color = True
    99         with_color = True
       
   100         pygmentspresent = True
   100     except ImportError:
   101     except ImportError:
   101         pass
   102         pass
   102 
   103 
   103 if not sys.stderr.isatty(): # check if the terminal is capable
   104 if not sys.stderr.isatty(): # check if the terminal is capable
   104     with_color = False
   105     with_color = False
  1648                     raise test.failureException(
  1649                     raise test.failureException(
  1649                         'server failed to start (HGPORT=%s)' % test._startport)
  1650                         'server failed to start (HGPORT=%s)' % test._startport)
  1650                 else:
  1651                 else:
  1651                     self.stream.write('\n')
  1652                     self.stream.write('\n')
  1652                     for line in lines:
  1653                     for line in lines:
  1653                         if with_color:
  1654                         if with_color and pygmentspresent:
  1654                             line = pygments.highlight(
  1655                             line = pygments.highlight(
  1655                                     line,
  1656                                     line,
  1656                                     lexers.DiffLexer(),
  1657                                     lexers.DiffLexer(),
  1657                                     formatters.Terminal256Formatter())
  1658                                     formatters.Terminal256Formatter())
  1658                         if PYTHON3:
  1659                         if PYTHON3: