diff options
author | Matthias Sohn | 2010-09-07 03:37:02 -0400 |
---|---|---|
committer | Code Review | 2010-09-07 03:37:02 -0400 |
commit | ab862b0af13a6ba83f956746ee170e618488f92a (patch) | |
tree | 54543dc4f2b4dd5069a8abe05f805a00812c1c91 /org.eclipse.egit.core.test | |
parent | d842c88527601fd4ff5cd8e9161a78ae05d58dd9 (diff) | |
parent | 0c166f43a8e1a60416bc20f707593c2ad69b1f4a (diff) | |
download | egit-ab862b0af13a6ba83f956746ee170e618488f92a.tar.gz egit-ab862b0af13a6ba83f956746ee170e618488f92a.tar.xz egit-ab862b0af13a6ba83f956746ee170e618488f92a.zip |
Merge "Fix deletion problem in EGit Core tests"
Diffstat (limited to 'org.eclipse.egit.core.test')
-rw-r--r-- | org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/TestUtils.java | 25 |
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 8ff9eb80d..98bfd9b1a 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 * |