8188894: jdk/jshell/ToolShiftTabTest.java failed with IllegalStateException
Reviewed-by: jlahoda
This commit is contained in:
parent
d60ccd7c4c
commit
9ecafd93f5
@ -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 class ToolShiftTabTest extends UITesting {
|
||||
|
||||
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");
|
||||
|
||||
|
@ -135,8 +135,19 @@ public class UITesting {
|
||||
}
|
||||
|
||||
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 @@ public class UITesting {
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user