Mercurial > hg
comparison tests/run-tests.py @ 47619:f0fbe8f4faa6
run-tests: enforce the drive letter from `getcwd` to upper case
For some reason os.getcwd() can return either `c:` or `C:` depending of which
binary you used on Windows. We normalize this to `C:` and the like. This fix
`test-run-tests.t` on windows as the drive letter in "$TESTTMP" was "wrongly"
set to 'c:/' if the test path wasn't explicitly specified.
Differential Revision: https://phab.mercurial-scm.org/D11035
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 10 Jul 2021 01:15:03 +0200 |
parents | eb611ecb435c |
children | 55a715c36e3b |
comparison
equal
deleted
inserted
replaced
47618:27ff81547d35 | 47619:f0fbe8f4faa6 |
---|---|
227 return p | 227 return p |
228 | 228 |
229 _bytes2sys = _sys2bytes | 229 _bytes2sys = _sys2bytes |
230 osenvironb = os.environ | 230 osenvironb = os.environ |
231 getcwdb = os.getcwd | 231 getcwdb = os.getcwd |
232 | |
233 if WINDOWS: | |
234 _getcwdb = getcwdb | |
235 | |
236 def getcwdb(): | |
237 cwd = _getcwdb() | |
238 if re.match(b'^[a-z]:', cwd): | |
239 # os.getcwd() is inconsistent on the capitalization of the drive | |
240 # letter, so adjust it. see https://bugs.python.org/issue40368 | |
241 cwd = cwd[0:1].upper() + cwd[1:] | |
242 return cwd | |
243 | |
232 | 244 |
233 # For Windows support | 245 # For Windows support |
234 wifexited = getattr(os, "WIFEXITED", lambda x: False) | 246 wifexited = getattr(os, "WIFEXITED", lambda x: False) |
235 | 247 |
236 # Whether to use IPv6 | 248 # Whether to use IPv6 |
3076 finally: | 3088 finally: |
3077 os.umask(oldmask) | 3089 os.umask(oldmask) |
3078 | 3090 |
3079 def _run(self, testdescs): | 3091 def _run(self, testdescs): |
3080 testdir = getcwdb() | 3092 testdir = getcwdb() |
3081 self._testdir = osenvironb[b'TESTDIR'] = getcwdb() | |
3082 # assume all tests in same folder for now | 3093 # assume all tests in same folder for now |
3083 if testdescs: | 3094 if testdescs: |
3084 pathname = os.path.dirname(testdescs[0]['path']) | 3095 pathname = os.path.dirname(testdescs[0]['path']) |
3085 if pathname: | 3096 if pathname: |
3086 testdir = os.path.join(testdir, pathname) | 3097 testdir = os.path.join(testdir, pathname) |