run-tests: extend PATH on Windows to include user installed scripts
This allows the test environment to see pylint.exe when installed with
`pip install --user`, since it isn't normally on PATH.
Differential Revision: https://phab.mercurial-scm.org/D9535
--- a/tests/run-tests.py Mon Dec 07 16:18:28 2020 -0500
+++ b/tests/run-tests.py Mon Dec 07 16:32:30 2020 -0500
@@ -3484,7 +3484,29 @@
path = os.environ['PATH'].split(os.pathsep)
while exedir in path:
path.remove(exedir)
- os.environ['PATH'] = os.pathsep.join([exedir] + path)
+
+ # Binaries installed by pip into the user area like pylint.exe may
+ # not be in PATH by default.
+ extra_paths = [exedir]
+ vi = sys.version_info
+ if 'APPDATA' in os.environ:
+ scripts_dir = os.path.join(
+ os.environ['APPDATA'],
+ 'Python',
+ 'Python%d%d' % (vi[0], vi[1]),
+ 'Scripts',
+ )
+
+ if vi.major == 2:
+ scripts_dir = os.path.join(
+ os.environ['APPDATA'],
+ 'Python',
+ 'Scripts',
+ )
+
+ extra_paths.append(scripts_dir)
+
+ os.environ['PATH'] = os.pathsep.join(extra_paths + path)
if not self._findprogram(pyexename):
print("WARNING: Cannot find %s in search path" % pyexename)