diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -326,6 +326,8 @@ return p +WINDOWS = os.name == r'nt' + if sys.executable: sysexecutable = sys.executable elif os.environ.get('PYTHONEXECUTABLE'): @@ -351,6 +353,24 @@ defaults = default_defaults.copy() +LOWER_DRIVE_RE_BYTES = re.compile(b'^[a-z]:') +LOWER_DRIVE_RE_STR = re.compile(b'^[a-z]:') + + +# run-test something put either "c:" or "C:" depending of how the test file +# is specified. This is annoying for testing run-tests.py. After chassing +# the rabbit for a while, I am just doing this stupid hack. +def adjust_drive(path): + if WINDOWS: + if isinstance(path, bytes): + has_drive = LOWER_DRIVE_RE_BYTES.match(path) + else: + has_drive = LOWER_DRIVE_RE_STR.match(path) + if has_drive: + path = path[0:1].upper() + path[1:] + return path + + def canonpath(path): return os.path.realpath(os.path.expanduser(path)) @@ -3057,12 +3077,12 @@ 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']) if pathname: testdir = os.path.join(testdir, pathname) + testdir = adjust_drive(testdir) self._testdir = osenvironb[b'TESTDIR'] = testdir if self.options.outputdir: self._outputdir = canonpath(_sys2bytes(self.options.outputdir))