mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8144009: ToolBox should have a cleanDirectory method
Added cleanDirectory method to ToolBox. Reviewed-by: jjg
This commit is contained in:
parent
68126c8ee9
commit
ea92f6bf06
14 changed files with 36 additions and 71 deletions
|
@ -34,6 +34,7 @@ public class SJavacTester {
|
|||
+ "portfile=testportfile,"
|
||||
+ "background=false";
|
||||
|
||||
final ToolBox tb = new ToolBox();
|
||||
final Path TEST_ROOT = Paths.get(getClass().getSimpleName());
|
||||
|
||||
// Generated sources that will test aspects of sjavac
|
||||
|
@ -53,7 +54,6 @@ public class SJavacTester {
|
|||
|
||||
void initialCompile() throws Exception {
|
||||
System.out.println("\nInitial compile of gensrc.");
|
||||
ToolBox tb = new ToolBox();
|
||||
tb.writeFile(GENSRC.resolve("alfa/omega/AINT.java"),
|
||||
"package alfa.omega; public interface AINT { void aint(); }");
|
||||
tb.writeFile(GENSRC.resolve("alfa/omega/A.java"),
|
||||
|
@ -101,30 +101,6 @@ public class SJavacTester {
|
|||
}
|
||||
}
|
||||
|
||||
void delete(final Path root) throws IOException {
|
||||
if (!Files.exists(root)) return;
|
||||
Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
|
||||
{
|
||||
Files.delete(file);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException e) throws IOException
|
||||
{
|
||||
if (e == null) {
|
||||
if (!dir.equals(root)) Files.delete(dir);
|
||||
return FileVisitResult.CONTINUE;
|
||||
} else {
|
||||
// directory iteration failed
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void compile(String... args) throws Exception {
|
||||
int rc = Main.go(args);
|
||||
if (rc != 0) throw new Exception("Error during compile!");
|
||||
|
@ -265,10 +241,4 @@ public class SJavacTester {
|
|||
throw new Exception("The dir should not differ! But it does!");
|
||||
}
|
||||
}
|
||||
|
||||
void clean(Path... listOfDirs) throws Exception {
|
||||
for (Path dir : listOfDirs) {
|
||||
delete(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue