comparison tests/run-tests.py @ 47308:bb4606f35d37

run-tests: enable color on Windows In setting up the CI for Windows on heptapod, I noticed it was complaining about color not being enabled because pygments wasn't installed- even though it was. I had initially disabled color on Windows when using Windows 7, because that didn't understand ANSI color codes and made a mess of the output. But now that it's been unsupported for over a year, I don't think we should care about it either. It's admittedly a hack to depend on Mercurial proper to enable color support in the terminal, but I didn't feel like duplicating that code. I'm under the impression that 3rd party stuff is supposed to use this runner in the Mercurial repo instead of using their own copy, so I think it's safe to assume the Mercurial code is available. If it's not, it won't break anything. Differential Revision: https://phab.mercurial-scm.org/D10760
author Matt Harbison <matt_harbison@yahoo.com>
date Thu, 06 May 2021 18:52:08 -0400
parents bcafcd779d2e
children af4d1a177548
comparison
equal deleted inserted replaced
47307:13dd5bb5492a 47308:bb4606f35d37
85 shellquote = pipes.quote 85 shellquote = pipes.quote
86 86
87 processlock = threading.Lock() 87 processlock = threading.Lock()
88 88
89 pygmentspresent = False 89 pygmentspresent = False
90 # ANSI color is unsupported prior to Windows 10 90 try: # is pygments installed
91 if os.name != 'nt': 91 import pygments
92 try: # is pygments installed 92 import pygments.lexers as lexers
93 import pygments 93 import pygments.lexer as lexer
94 import pygments.lexers as lexers 94 import pygments.formatters as formatters
95 import pygments.lexer as lexer 95 import pygments.token as token
96 import pygments.formatters as formatters 96 import pygments.style as style
97 import pygments.token as token 97
98 import pygments.style as style 98 if os.name == 'nt':
99 99 hgpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
100 pygmentspresent = True 100 sys.path.append(hgpath)
101 difflexer = lexers.DiffLexer() 101 try:
102 terminal256formatter = formatters.Terminal256Formatter() 102 from mercurial import win32 # pytype: disable=import-error
103 except ImportError: 103
104 pass 104 # Don't check the result code because it fails on heptapod, but
105 # something is able to convert to color anyway.
106 win32.enablevtmode()
107 finally:
108 sys.path = sys.path[:-1]
109
110 pygmentspresent = True
111 difflexer = lexers.DiffLexer()
112 terminal256formatter = formatters.Terminal256Formatter()
113 except ImportError:
114 pass
105 115
106 if pygmentspresent: 116 if pygmentspresent:
107 117
108 class TestRunnerStyle(style.Style): 118 class TestRunnerStyle(style.Style):
109 default_style = "" 119 default_style = ""