RFR: 8208227: tools/jdeps/DotFileTest.java fails on Win-X64
Jonathan Gibbons
jonathan.gibbons at oracle.com
Wed Jul 25 22:00:26 UTC 2018
Please review a simple fix for a P2 (tier1) langtools test failure.
It's Yet Another Example of using Files.delete on Windows and expecting
it to work.
The fix is to replace the usage with more robust library code, such as
that provided
in the ToolBox test-utility class.
Webrev: http://cr.openjdk.java.net/~jjg/8208227/webrev.00/
JBS: https://bugs.openjdk.java.net/browse/JDK-8208227
The diff is small enough to also include inline:
--- old/test/langtools/tools/jdeps/DotFileTest.java 2018-07-25 14:51:38.032332248 -0700
+++ new/test/langtools/tools/jdeps/DotFileTest.java 2018-07-25 14:51:37.644315078 -0700
@@ -27,7 +27,8 @@
* @summary Basic tests for jdeps -dotoutput option
* @modules java.management
* 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
*/
@@ -43,6 +44,8 @@
import java.util.regex.*;
import java.util.stream.Collectors;
+import toolbox.ToolBox;
+
public class DotFileTest {
public static void main(String... args) throws Exception {
int errors = 0;
@@ -51,9 +54,11 @@
throw new Exception(errors + " errors found");
}
+ final ToolBox toolBox;
final Path dir;
final Path dotoutput;
DotFileTest() {
+ this.toolBox = new ToolBox();
this.dir = Paths.get(System.getProperty("test.classes", "."));
this.dotoutput = dir.resolve("dots");
}
@@ -169,12 +174,10 @@
Map<String,String> jdeps(List<String> args, Path dotfile) throws IOException {
if (Files.exists(dotoutput)) {
- try (DirectoryStream<Path> stream = Files.newDirectoryStream(dotoutput)) {
- for (Path p : stream) {
- Files.delete(p);
- }
- }
- Files.delete(dotoutput);
+ // delete contents of directory, then directory,
+ // waiting for confirmation on Windows
+ toolBox.cleanDirectory(dotoutput);
+ toolBox.deleteFiles(dotoutput);
}
// invoke jdeps
StringWriter sw = new StringWriter();
More information about the compiler-dev
mailing list