8165564: langtools\test\jdk\jshell\CommandCompletionTest.java fails on some windows
Summary: Ignoring non-existent default FileSystem roots.
Reviewed-by: rfield
--- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Fri Dec 02 14:15:43 2016 -0800
+++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java Mon Dec 05 19:42:42 2016 +0100
@@ -1091,6 +1091,7 @@
}
if (path.isEmpty()) {
StreamSupport.stream(FileSystems.getDefault().getRootDirectories().spliterator(), false)
+ .filter(root -> Files.exists(root))
.filter(root -> accept.test(root) && root.toString().startsWith(prefix))
.map(root -> new ArgSuggestion(root.toString()))
.forEach(result::add);
--- a/langtools/test/jdk/jshell/CommandCompletionTest.java Fri Dec 02 14:15:43 2016 -0800
+++ b/langtools/test/jdk/jshell/CommandCompletionTest.java Mon Dec 05 19:42:42 2016 +0100
@@ -46,6 +46,7 @@
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
import org.testng.annotations.Test;
@@ -144,7 +145,7 @@
Compiler compiler = new Compiler();
assertCompletion("/o|", false, "/open ");
List<String> p1 = listFiles(Paths.get(""));
- FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString()));
+ getRootDirectories().forEach(s -> p1.add(s.toString()));
Collections.sort(p1);
assertCompletion("/open |", false, p1.toArray(new String[p1.size()]));
Path classDir = compiler.getClassDir();
@@ -157,7 +158,7 @@
assertCompletion("/s|", false, "/save ", "/set ");
List<String> p1 = listFiles(Paths.get(""));
Collections.addAll(p1, "-all ", "-history ", "-start ");
- FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString()));
+ getRootDirectories().forEach(s -> p1.add(s.toString()));
Collections.sort(p1);
assertCompletion("/save |", false, p1.toArray(new String[p1.size()]));
Path classDir = compiler.getClassDir();
@@ -198,7 +199,7 @@
public void testSet() throws IOException {
List<String> p1 = listFiles(Paths.get(""));
- FileSystems.getDefault().getRootDirectories().forEach(s -> p1.add(s.toString()));
+ getRootDirectories().forEach(s -> p1.add(s.toString()));
Collections.sort(p1);
String[] modes = {"concise ", "normal ", "silent ", "verbose "};
@@ -267,4 +268,13 @@
(Files.isDirectory(file) ||
file.getFileName().toString().endsWith(".jar") ||
file.getFileName().toString().endsWith(".zip"));
+
+ private static Iterable<? extends Path> getRootDirectories() {
+ return StreamSupport.stream(FileSystems.getDefault()
+ .getRootDirectories()
+ .spliterator(),
+ false)
+ .filter(p -> Files.exists(p))
+ .collect(Collectors.toList());
+ }
}