Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
index 8ff9eb80d7..98bfd9b1a4 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java
@@ -47,15 +47,32 @@ public class TestUtils {
for (int i = 0; i < files.length; ++i) {
if (files[i].isDirectory())
deleteRecursive(files[i]);
- else if (!files[i].delete())
- throw new IOException(files[i] + " in use or undeletable");
+ else
+ deleteFile(files[i]);
}
}
- if (!d.delete())
- throw new IOException(d + " in use or undeletable");
+ deleteFile(d);
assert !d.exists();
}
+ private void deleteFile(File file) throws IOException{
+ boolean deleted = false;
+ for (int i = 0; i < 10; i++) {
+ if (file.delete()) {
+ deleted = true;
+ break;
+ }
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ System.out.println(">>> retried deleting " + file.getAbsolutePath());
+ }
+ if (!deleted)
+ throw new IOException("Retried 10 times. Could not delete " + file.getAbsolutePath());
+ }
+
/**
* Create a "temporary" directory
*

Back to the top