8208227: tools/jdeps/DotFileTest.java fails on Win-X64

Reviewed-by: darcy
This commit is contained in:
Jonathan Gibbons 2018-07-25 17:26:35 -07:00
parent 2517ca3937
commit f0e9643542

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -27,7 +27,8 @@
* @summary Basic tests for jdeps -dotoutput option * @summary Basic tests for jdeps -dotoutput option
* @modules java.management * @modules java.management
* jdk.jdeps/com.sun.tools.jdeps * jdk.jdeps/com.sun.tools.jdeps
* @build Test p.Foo p.Bar * @library /tools/lib
* @build toolbox.ToolBox Test p.Foo p.Bar
* @run main DotFileTest * @run main DotFileTest
*/ */
@ -43,6 +44,8 @@ import java.util.*;
import java.util.regex.*; import java.util.regex.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import toolbox.ToolBox;
public class DotFileTest { public class DotFileTest {
public static void main(String... args) throws Exception { public static void main(String... args) throws Exception {
int errors = 0; int errors = 0;
@ -51,9 +54,11 @@ public class DotFileTest {
throw new Exception(errors + " errors found"); throw new Exception(errors + " errors found");
} }
final ToolBox toolBox;
final Path dir; final Path dir;
final Path dotoutput; final Path dotoutput;
DotFileTest() { DotFileTest() {
this.toolBox = new ToolBox();
this.dir = Paths.get(System.getProperty("test.classes", ".")); this.dir = Paths.get(System.getProperty("test.classes", "."));
this.dotoutput = dir.resolve("dots"); this.dotoutput = dir.resolve("dots");
} }
@ -169,12 +174,10 @@ public class DotFileTest {
Map<String,String> jdeps(List<String> args, Path dotfile) throws IOException { Map<String,String> jdeps(List<String> args, Path dotfile) throws IOException {
if (Files.exists(dotoutput)) { if (Files.exists(dotoutput)) {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(dotoutput)) { // delete contents of directory, then directory,
for (Path p : stream) { // waiting for confirmation on Windows
Files.delete(p); toolBox.cleanDirectory(dotoutput);
} toolBox.deleteFiles(dotoutput);
}
Files.delete(dotoutput);
} }
// invoke jdeps // invoke jdeps
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();