8013647: JPRT unable to clean-up after tests that leave file trees with loops
authoralanb
Tue, 30 Apr 2013 21:19:24 +0100
changeset 17203 be1cff0d6750
parent 17202 5e820bcaed07
child 17204 d0540971275f
8013647: JPRT unable to clean-up after tests that leave file trees with loops Reviewed-by: chegar, tbell
jdk/test/java/nio/file/Files/walkFileTree/MaxDepth.java
jdk/test/java/nio/file/Files/walkFileTree/SkipSiblings.java
jdk/test/java/nio/file/Files/walkFileTree/SkipSubtree.java
jdk/test/java/nio/file/Files/walkFileTree/TerminateWalk.java
--- a/jdk/test/java/nio/file/Files/walkFileTree/MaxDepth.java	Tue Apr 30 13:12:54 2013 -0700
+++ b/jdk/test/java/nio/file/Files/walkFileTree/MaxDepth.java	Tue Apr 30 21:19:24 2013 +0100
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Unit test for Files.walkFileTree to test maxDepth parameter
+ * @library ../..
  * @compile MaxDepth.java CreateFileTree.java
  * @run main MaxDepth
  */
@@ -34,9 +35,16 @@
 import java.util.*;
 
 public class MaxDepth {
-    public static void main(String[] args) throws Exception {
-        final Path top = CreateFileTree.create();
+    public static void main(String[] args) throws IOException {
+        Path top = CreateFileTree.create();
+        try {
+            test(top);
+        } finally {
+            TestUtil.removeAll(top);
+        }
+    }
 
+    static void test(final Path top) throws IOException {
         for (int i=0; i<5; i++) {
             Set<FileVisitOption> opts = Collections.emptySet();
             final int maxDepth = i;
--- a/jdk/test/java/nio/file/Files/walkFileTree/SkipSiblings.java	Tue Apr 30 13:12:54 2013 -0700
+++ b/jdk/test/java/nio/file/Files/walkFileTree/SkipSiblings.java	Tue Apr 30 21:19:24 2013 +0100
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Unit test for Files.walkFileTree to test SKIP_SIBLINGS return value
+ * @library ../..
  * @compile SkipSiblings.java CreateFileTree.java
  * @run main SkipSiblings
  */
@@ -55,9 +56,16 @@
     }
 
     public static void main(String[] args) throws Exception {
-        Path dir = CreateFileTree.create();
+        Path top = CreateFileTree.create();
+        try {
+            test(top);
+        } finally {
+            TestUtil.removeAll(top);
+        }
+    }
 
-        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
+    static void test(final Path start) throws IOException {
+        Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
             @Override
             public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
                 check(dir);
--- a/jdk/test/java/nio/file/Files/walkFileTree/SkipSubtree.java	Tue Apr 30 13:12:54 2013 -0700
+++ b/jdk/test/java/nio/file/Files/walkFileTree/SkipSubtree.java	Tue Apr 30 21:19:24 2013 +0100
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Unit test for Files.walkFileTree to test SKIP_SUBTREE return value
+ * @library ../..
  * @compile SkipSubtree.java CreateFileTree.java
  * @run main SkipSubtree
  */
@@ -58,9 +59,16 @@
     }
 
     public static void main(String[] args) throws Exception {
-        Path dir = CreateFileTree.create();
+        Path top = CreateFileTree.create();
+        try {
+            test(top);
+        } finally {
+            TestUtil.removeAll(top);
+        }
+    }
 
-        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
+    static void test(final Path start) throws IOException {
+        Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
             @Override
             public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
                 check(dir);
--- a/jdk/test/java/nio/file/Files/walkFileTree/TerminateWalk.java	Tue Apr 30 13:12:54 2013 -0700
+++ b/jdk/test/java/nio/file/Files/walkFileTree/TerminateWalk.java	Tue Apr 30 21:19:24 2013 +0100
@@ -24,6 +24,7 @@
 /*
  * @test
  * @summary Unit test for Files.walkFileTree to test TERMINATE return value
+ * @library ../..
  * @compile TerminateWalk.java CreateFileTree.java
  * @run main TerminateWalk
  */
@@ -50,9 +51,16 @@
     }
 
     public static void main(String[] args) throws Exception {
-        Path dir = CreateFileTree.create();
+        Path top = CreateFileTree.create();
+        try {
+            test(top);
+        } finally {
+            TestUtil.removeAll(top);
+        }
+    }
 
-        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
+    static void test(Path start) throws IOException {
+        Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
             @Override
             public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
                 return maybeTerminate();