Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2010-09-06 16:09:48 +0000
committerJens Baumgart2010-09-06 16:09:48 +0000
commit0c166f43a8e1a60416bc20f707593c2ad69b1f4a (patch)
tree0c2244262396037d83ad31fda948637e1666b836 /org.eclipse.egit.core.test/src
parentbd0d67f1783d314a7eec23c903acebfac62df168 (diff)
downloadegit-0c166f43a8e1a60416bc20f707593c2ad69b1f4a.tar.gz
egit-0c166f43a8e1a60416bc20f707593c2ad69b1f4a.tar.xz
egit-0c166f43a8e1a60416bc20f707593c2ad69b1f4a.zip
Fix deletion problem in EGit Core tests
EGit core tests sometimes fail because TestUtils.deleteRecursive can not delete a file. To workaround the problem the deletion is retried 10 times. Change-Id: Ia25c9304884c95f54e8e7b98ed49dd044fa7b95b Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Diffstat (limited to 'org.eclipse.egit.core.test/src')
-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