diff options
-rw-r--r-- | testing/src/org/aspectj/testing/harness/bridge/Sandbox.java | 5 | ||||
-rw-r--r-- | testing/src/org/aspectj/testing/harness/bridge/Validator.java | 19 |
2 files changed, 18 insertions, 6 deletions
diff --git a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java index 0e0113fc3..3ad6aad10 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java +++ b/testing/src/org/aspectj/testing/harness/bridge/Sandbox.java @@ -182,6 +182,11 @@ public class Sandbox { if (null != command) { command = null; } + // also try to clear sandbox/filesystem. + // If locked by suite, we can't. + if (null != validator) { + validator.deleteTempFiles(true); + } } // /** diff --git a/testing/src/org/aspectj/testing/harness/bridge/Validator.java b/testing/src/org/aspectj/testing/harness/bridge/Validator.java index a7a43db08..e5f544356 100644 --- a/testing/src/org/aspectj/testing/harness/bridge/Validator.java +++ b/testing/src/org/aspectj/testing/harness/bridge/Validator.java @@ -507,12 +507,16 @@ public class Validator { public void deleteTempFiles(boolean reportFailures) { if (null == locker) { for (ListIterator iter = tempFiles.listIterator(); iter.hasNext();) { - deleteFile((File) iter.next(), reportFailures); + if (deleteFile((File) iter.next(), reportFailures)) { + iter.remove(); + } } for (ListIterator iter = sandboxes.listIterator(); iter.hasNext();) { Sandbox sandbox = (Sandbox) iter.next(); // XXX assumes all dirs are in sandboxDir - deleteFile(sandbox.sandboxDir, reportFailures); + if (deleteFile(sandbox.sandboxDir, reportFailures)) { + iter.remove(); + } } } } @@ -528,20 +532,23 @@ public class Validator { } - private void deleteFile(File file, boolean reportFailures) { + private boolean deleteFile(File file, boolean reportFailures) { if (null == file) { if (reportFailures) { fail("unable to delete null file"); } - return; + return true; // null file - skip } FileUtil.deleteContents(file); if (file.exists()) { file.delete(); } - if (reportFailures && file.exists()) { - fail("unable to delete " + file); + if (!file.exists()) { + return true; + } else if (reportFailures) { + fail("unable to delete " + file); } + return false; } /** @throws IllegalStateException if handler is null */ |