]> source.dussan.org Git - aspectj.git/commitdiff
-keepTemp implementation: Suite run iterator calls clearCommand, which also calls...
authorwisberg <wisberg>
Wed, 7 May 2003 06:05:52 +0000 (06:05 +0000)
committerwisberg <wisberg>
Wed, 7 May 2003 06:05:52 +0000 (06:05 +0000)
testing/src/org/aspectj/testing/harness/bridge/Sandbox.java
testing/src/org/aspectj/testing/harness/bridge/Validator.java

index 0e0113fc36607c6413769998e91c26bdbfcbd826..3ad6aad10d2b08561c1ca63627f8867e1bd4aec6 100644 (file)
@@ -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);
+        }
     }
     
 //    /** 
index a7a43db08eb10d53ba1b9b833fd5d5ce8ccfe8d0..e5f5443567da205f5498de182bb4f90ac0e374d6 100644 (file)
@@ -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 */