Skip to content

Commit 71788c6

Browse files
committed
8271287: jdk/jshell/CommandCompletionTest.java fails with "lists don't have the same size expected"
Reviewed-by: vromero
1 parent ba7d550 commit 71788c6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/langtools/jdk/jshell/CommandCompletionTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,22 @@ public void testClassPath() throws IOException {
332332
public void testUserHome() throws IOException {
333333
List<String> completions;
334334
Path home = Paths.get(System.getProperty("user.home"));
335+
String selectedFile;
336+
try (Stream<Path> content = Files.list(home)) {
337+
selectedFile = content.filter(CLASSPATH_FILTER)
338+
.findAny()
339+
.map(file -> file.getFileName().toString())
340+
.get();
341+
}
335342
try (Stream<Path> content = Files.list(home)) {
336343
completions = content.filter(CLASSPATH_FILTER)
344+
.filter(file -> file.getFileName().toString().startsWith(selectedFile))
337345
.map(file -> file.getFileName().toString() + (Files.isDirectory(file) ? "/" : ""))
338346
.sorted()
339347
.collect(Collectors.toList());
340348
}
341349
testNoStartUp(
342-
a -> assertCompletion(a, "/env --class-path ~/|", false, completions.toArray(new String[completions.size()]))
350+
a -> assertCompletion(a, "/env --class-path ~/" + selectedFile + "|", false, completions.toArray(new String[completions.size()]))
343351
);
344352
}
345353

0 commit comments

Comments
 (0)