# HG changeset patch # User rfield # Date 1513203672 28800 # Node ID 4f9683bf092372811dacdc1eda20e1453b6926fe # Parent 1f38b6c89f8ae9e1a33da6e995c318bbd2893865 8188894: jdk/jshell/ToolShiftTabTest.java failed with IllegalStateException Reviewed-by: jlahoda diff -r 1f38b6c89f8a -r 4f9683bf0923 test/langtools/jdk/jshell/ToolShiftTabTest.java --- a/test/langtools/jdk/jshell/ToolShiftTabTest.java Wed Dec 13 10:56:50 2017 -0800 +++ b/test/langtools/jdk/jshell/ToolShiftTabTest.java Wed Dec 13 14:21:12 2017 -0800 @@ -23,7 +23,7 @@ /** * @test - * @bug 8166334 + * @bug 8166334 8188894 * @summary test shift-tab shortcuts "fixes" * @modules * jdk.jshell/jdk.internal.jshell.tool.resources:open @@ -107,11 +107,12 @@ public void testFixImport() throws Exception { doRunTest((inputSink, out) -> { - inputSink.write("Frame"); - inputSink.write(FIX + "i"); - inputSink.write("1"); - inputSink.write(".WIDTH\n"); - waitOutput(out, "==> 1"); + do { + inputSink.write("Frame"); + inputSink.write(FIX + "i"); + inputSink.write("1"); + inputSink.write(".WIDTH\n"); + } while (!waitOutput(out, "==> 1", "Results may be incomplete")); inputSink.write("/import\n"); waitOutput(out, "| import java.awt.Frame"); diff -r 1f38b6c89f8a -r 4f9683bf0923 test/langtools/jdk/jshell/UITesting.java --- a/test/langtools/jdk/jshell/UITesting.java Wed Dec 13 10:56:50 2017 -0800 +++ b/test/langtools/jdk/jshell/UITesting.java Wed Dec 13 14:21:12 2017 -0800 @@ -135,8 +135,19 @@ } protected void waitOutput(StringBuilder out, String expected) { + waitOutput(out, expected, null); + } + + // Return true if expected is found, false if secondary is found, + // otherwise, time out with an IllegalStateException + protected boolean waitOutput(StringBuilder out, String expected, String secondary) { expected = expected.replaceAll("\n", laxLineEndings ? "\r?\n" : System.getProperty("line.separator")); Pattern expectedPattern = Pattern.compile(expected, Pattern.DOTALL); + Pattern secondaryPattern = null; + if (secondary != null) { + secondary = secondary.replaceAll("\n", laxLineEndings ? "\r?\n" : System.getProperty("line.separator")); + secondaryPattern = Pattern.compile(secondary, Pattern.DOTALL); + } synchronized (out) { long s = System.currentTimeMillis(); @@ -144,7 +155,14 @@ Matcher m = expectedPattern.matcher(out); if (m.find()) { out.delete(0, m.end()); - return ; + return true; + } + if (secondaryPattern != null) { + m = secondaryPattern.matcher(out); + if (m.find()) { + out.delete(0, m.end()); + return false; + } } long e = System.currentTimeMillis(); if ((e - s) > TIMEOUT) {