# HG changeset patch # User Pierre-Yves David # Date 1625872503 -7200 # Node ID f0fbe8f4faa682ecc08e9e53025ba7d87d5f5806 # Parent 27ff81547d35e1943f73692604227246680665b5 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 diff -r 27ff81547d35 -r f0fbe8f4faa6 tests/run-tests.py --- a/tests/run-tests.py Mon Jul 12 03:30:04 2021 +0200 +++ b/tests/run-tests.py Sat Jul 10 01:15:03 2021 +0200 @@ -230,6 +230,18 @@ osenvironb = os.environ getcwdb = os.getcwd +if WINDOWS: + _getcwdb = getcwdb + + def getcwdb(): + cwd = _getcwdb() + if re.match(b'^[a-z]:', cwd): + # os.getcwd() is inconsistent on the capitalization of the drive + # letter, so adjust it. see https://bugs.python.org/issue40368 + cwd = cwd[0:1].upper() + cwd[1:] + return cwd + + # For Windows support wifexited = getattr(os, "WIFEXITED", lambda x: False) @@ -3078,7 +3090,6 @@ def _run(self, testdescs): testdir = getcwdb() - self._testdir = osenvironb[b'TESTDIR'] = getcwdb() # assume all tests in same folder for now if testdescs: pathname = os.path.dirname(testdescs[0]['path'])