[Lldb-commits] [PATCH] D18912: sleep and retry on failure to delete temp file in tests

Adrian McCarthy via lldb-commits lldb-commits at lists.llvm.org
Fri Apr 8 15:13:55 PDT 2016


amccarth created this revision.
amccarth added a reviewer: zturner.
amccarth added a subscriber: lldb-commits.

This solves a flaky test on Windows.

We have similar logic elsewhere for log files.  I considered trying to combine them, but since they are methods of different objects, there wasn't really a clean approach.

http://reviews.llvm.org/D18912

Files:
  packages/Python/lldbsuite/test/lldbtest.py

Index: packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- packages/Python/lldbsuite/test/lldbtest.py
+++ packages/Python/lldbsuite/test/lldbtest.py
@@ -1996,4 +1996,10 @@
     @classmethod
     def RemoveTempFile(cls, file):
         if os.path.exists(file):
-            os.remove(file)
+            try:
+                os.remove(file)
+            except:
+                # On Windows, we can sometimes need a retry because antimalware may
+                # briefly hold the file open.
+                time.sleep(0.5)
+                os.remove(file)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18912.53098.patch
Type: text/x-patch
Size: 622 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160408/ff4ff555/attachment.bin>


More information about the lldb-commits mailing list