[PATCH] D57533: lit: support long paths on Windows

Saleem Abdulrasool via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 11:59:49 PST 2019


compnerd created this revision.
compnerd added reviewers: rnk, smeenai.
Herald added a subscriber: delcypher.
Herald added a reviewer: serge-sans-paille.

Use ctypes to call into `RemoveDirectoryW` with the extended NT path to allow us to remove paths which exceed 261 characters on Windows.  This functionality is exercised by swift's test suite.


Repository:
  rL LLVM

https://reviews.llvm.org/D57533

Files:
  utils/lit/lit/TestRunner.py


Index: utils/lit/lit/TestRunner.py
===================================================================
--- utils/lit/lit/TestRunner.py
+++ utils/lit/lit/TestRunner.py
@@ -607,7 +607,12 @@
                 if not recursive:
                     stderr.write("Error: %s is a directory\n" % path)
                     exitCode = 1
-                shutil.rmtree(path, onerror = on_rm_error if force else None)
+                if platform.system() == 'Windows':
+                    import ctypes
+                    path = os.path.abspath(path)
+                    ctypes.windll.kernel32.RemoveDirectoryW(r'\\?\%s' % path)
+                else:
+                    shutil.rmtree(path, onerror = on_rm_error if force else None)
             else:
                 if force and not os.access(path, os.W_OK):
                     os.chmod(path,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57533.184562.patch
Type: text/x-patch
Size: 844 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/15781572/attachment.bin>


More information about the llvm-commits mailing list