[lit] [windows] Make sure to convert all path separators to backslashes in NT style...
authorMartin Storsjö <martin@martin.st>
Fri, 13 Dec 2019 21:28:19 +0000 (21:28 +0000)
committerMartin Storsjö <martin@martin.st>
Tue, 17 Dec 2019 08:08:53 +0000 (10:08 +0200)
E.g. the mingw python distributed in msys2 (the mingw one, which is a
normal win32 application and doesn't use the msys2 runtime itself),
despite being a normal win32 python, still uses forward slashes. This
works fine for other cases (many, but not all), but when constructing a
raw NT path, all path separators must be backslashes.

Differential Revision: https://reviews.llvm.org/D71490

llvm/utils/lit/lit/util.py

index c662be3..fa752d0 100644 (file)
@@ -151,6 +151,10 @@ def mkdir(path):
             from ctypes import GetLastError, WinError
 
             path = os.path.abspath(path)
+            # Make sure that the path uses backslashes here, in case
+            # python would have happened to use forward slashes, as the
+            # NT path format only supports backslashes.
+            path = path.replace('/', '\\')
             NTPath = to_unicode(r'\\?\%s' % path)
             if not windll.kernel32.CreateDirectoryW(NTPath, None):
                 raise WinError(GetLastError())