提交 2e027391 编写于 作者: A alanb

8013647: JPRT unable to clean-up after tests that leave file trees with loops

Reviewed-by: chegar, tbell
上级 57cc8031
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @summary Unit test for Files.walkFileTree to test maxDepth parameter * @summary Unit test for Files.walkFileTree to test maxDepth parameter
* @library ../..
* @compile MaxDepth.java CreateFileTree.java * @compile MaxDepth.java CreateFileTree.java
* @run main MaxDepth * @run main MaxDepth
*/ */
...@@ -34,9 +35,16 @@ import java.io.IOException; ...@@ -34,9 +35,16 @@ import java.io.IOException;
import java.util.*; import java.util.*;
public class MaxDepth { public class MaxDepth {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws IOException {
final Path top = CreateFileTree.create(); 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++) { for (int i=0; i<5; i++) {
Set<FileVisitOption> opts = Collections.emptySet(); Set<FileVisitOption> opts = Collections.emptySet();
final int maxDepth = i; final int maxDepth = i;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @summary Unit test for Files.walkFileTree to test SKIP_SIBLINGS return value * @summary Unit test for Files.walkFileTree to test SKIP_SIBLINGS return value
* @library ../..
* @compile SkipSiblings.java CreateFileTree.java * @compile SkipSiblings.java CreateFileTree.java
* @run main SkipSiblings * @run main SkipSiblings
*/ */
...@@ -55,9 +56,16 @@ public class SkipSiblings { ...@@ -55,9 +56,16 @@ public class SkipSiblings {
} }
public static void main(String[] args) throws Exception { 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 @Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
check(dir); check(dir);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @summary Unit test for Files.walkFileTree to test SKIP_SUBTREE return value * @summary Unit test for Files.walkFileTree to test SKIP_SUBTREE return value
* @library ../..
* @compile SkipSubtree.java CreateFileTree.java * @compile SkipSubtree.java CreateFileTree.java
* @run main SkipSubtree * @run main SkipSubtree
*/ */
...@@ -58,9 +59,16 @@ public class SkipSubtree { ...@@ -58,9 +59,16 @@ public class SkipSubtree {
} }
public static void main(String[] args) throws Exception { 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 @Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
check(dir); check(dir);
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
/* /*
* @test * @test
* @summary Unit test for Files.walkFileTree to test TERMINATE return value * @summary Unit test for Files.walkFileTree to test TERMINATE return value
* @library ../..
* @compile TerminateWalk.java CreateFileTree.java * @compile TerminateWalk.java CreateFileTree.java
* @run main TerminateWalk * @run main TerminateWalk
*/ */
...@@ -50,9 +51,16 @@ public class TerminateWalk { ...@@ -50,9 +51,16 @@ public class TerminateWalk {
} }
public static void main(String[] args) throws Exception { 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 @Override
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) { public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
return maybeTerminate(); return maybeTerminate();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册