[llvm] [LIT][Cygwin] Skip pre-check for existence in mkdir-p (PR #163948)

Tomohiro Kashiwada via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 18 02:38:27 PDT 2025


================
@@ -131,48 +132,17 @@ def abs_path_preserve_drive(path):
         # Since Python 3.8, os.path.realpath resolves sustitute drives,
         # so we should not use it. In Python 3.7, os.path.realpath
         # was implemented as os.path.abspath.
+        if isinstance(path, pathlib.Path):
+            return path.absolute()
         return os.path.abspath(path)
     else:
         # On UNIX, the current directory always has symbolic links resolved,
         # so any program accepting relative paths cannot preserve symbolic
         # links in paths and we should always use os.path.realpath.
+        if isinstance(path, pathlib.Path):
+            return path.resolve()
         return os.path.realpath(path)
 
-def mkdir(path):
-    try:
-        if platform.system() == "Windows":
-            from ctypes import windll
-            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())
-        else:
-            os.mkdir(path)
-    except OSError:
-        e = sys.exc_info()[1]
-        # ignore EEXIST, which may occur during a race condition
----------------
kikairoya wrote:

Previously, all EEXIST errors were ignored.
We should indeed ignore races between concurrent `mkdir target`s, but I don't see any reason to allow races between `touch target` and `mkdir target`.
Since `pathlib`'s `exist_ok=True` behaves this way, the test `shtest-glob.py` has been updated to reflect the new behavior.

https://github.com/llvm/llvm-project/pull/163948


More information about the llvm-commits mailing list