8178035: MergedTabShiftTabTest sometimes time outs
Splitting MergedTabShiftTabTest into two tests, increasing timeout. Reviewed-by: rfield
This commit is contained in:
parent
2114b9fa01
commit
c71e9e0626
@ -28,6 +28,7 @@
|
||||
* @modules
|
||||
* jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* jdk.jshell/jdk.internal.jshell.tool.resources:open
|
||||
* jdk.jshell/jdk.jshell:open
|
||||
* @library /tools/lib
|
||||
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
|
||||
|
124
langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java
Normal file
124
langtools/test/jdk/jshell/MergedTabShiftTabCommandTest.java
Normal file
@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8177076
|
||||
* @modules
|
||||
* jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* jdk.jshell/jdk.internal.jshell.tool.resources:open
|
||||
* jdk.jshell/jdk.jshell:open
|
||||
* @library /tools/lib
|
||||
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
|
||||
* @build Compiler UITesting
|
||||
* @build MergedTabShiftTabCommandTest
|
||||
* @run testng MergedTabShiftTabCommandTest
|
||||
*/
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test
|
||||
public class MergedTabShiftTabCommandTest extends UITesting {
|
||||
|
||||
public void testCommand() throws Exception {
|
||||
doRunTest((inputSink, out) -> {
|
||||
inputSink.write("1\n");
|
||||
waitOutput(out, "\u0005");
|
||||
inputSink.write("/\011");
|
||||
waitOutput(out, ".*/edit.*/list.*\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, ".*\n/edit\n" + Pattern.quote(getResource("help.edit.summary")) +
|
||||
"\n.*\n/list\n" + Pattern.quote(getResource("help.list.summary")) +
|
||||
".*\n\n" + Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, "/!\n" +
|
||||
Pattern.quote(getResource("help.bang")) + "\n" +
|
||||
"\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
|
||||
"\r\u0005/");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, "/-<n>\n" +
|
||||
Pattern.quote(getResource("help.previous")) + "\n" +
|
||||
"\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
|
||||
"\r\u0005/");
|
||||
|
||||
inputSink.write("lis\011");
|
||||
waitOutput(out, "list $");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, ".*-all.*" +
|
||||
"\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.list.summary")) + "\n\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/list ");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.list").replaceAll("\t", " ")));
|
||||
|
||||
inputSink.write("\u0003/env \011");
|
||||
waitOutput(out, "\u0005/env -\n" +
|
||||
"-add-exports -add-modules -class-path -module-path \n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, "-add-exports -add-modules -class-path -module-path \n" +
|
||||
"\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.env.summary")) + "\n\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.env").replaceAll("\t", " ")) + "\n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, "-add-exports -add-modules -class-path -module-path \n" +
|
||||
"\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\u0003/exit \011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit ");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.exit")) + "\n" +
|
||||
"\r\u0005/exit ");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit ");
|
||||
inputSink.write("\u0003/doesnotexist\011");
|
||||
waitOutput(out, "\u0005/doesnotexist\n" +
|
||||
Pattern.quote(getResource("jshell.console.no.such.command")) + "\n" +
|
||||
"\n" +
|
||||
"\r\u0005/doesnotexist");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -32,8 +32,8 @@
|
||||
* @library /tools/lib
|
||||
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
|
||||
* @build Compiler UITesting
|
||||
* @build MergedTabShiftTabTest
|
||||
* @run testng MergedTabShiftTabTest
|
||||
* @build MergedTabShiftTabExpressionTest
|
||||
* @run testng/timeout=300 MergedTabShiftTabExpressionTest
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
@ -41,97 +41,15 @@ import java.lang.reflect.Field;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import jdk.jshell.JShell;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test
|
||||
public class MergedTabShiftTabTest extends UITesting {
|
||||
|
||||
public void testCommand() throws Exception {
|
||||
doRunTest((inputSink, out) -> {
|
||||
inputSink.write("1\n");
|
||||
waitOutput(out, "\u0005");
|
||||
inputSink.write("/\011");
|
||||
waitOutput(out, ".*/edit.*/list.*\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, ".*\n/edit\n" + Pattern.quote(getResource("help.edit.summary")) +
|
||||
"\n.*\n/list\n" + Pattern.quote(getResource("help.list.summary")) +
|
||||
".*\n\n" + Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, "/!\n" +
|
||||
Pattern.quote(getResource("help.bang")) + "\n" +
|
||||
"\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
|
||||
"\r\u0005/");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, "/-<n>\n" +
|
||||
Pattern.quote(getResource("help.previous")) + "\n" +
|
||||
"\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.next.command.doc")) + "\n" +
|
||||
"\r\u0005/");
|
||||
|
||||
inputSink.write("lis\011");
|
||||
waitOutput(out, "list $");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, ".*-all.*" +
|
||||
"\n\n" + Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n\r\u0005/");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.list.summary")) + "\n\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/list ");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.list").replaceAll("\t", " ")));
|
||||
|
||||
inputSink.write("\u0003/env \011");
|
||||
waitOutput(out, "\u0005/env -\n" +
|
||||
"-add-exports -add-modules -class-path -module-path \n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, "-add-exports -add-modules -class-path -module-path \n" +
|
||||
"\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.env.summary")) + "\n\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.env").replaceAll("\t", " ")) + "\n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, "-add-exports -add-modules -class-path -module-path \n" +
|
||||
"\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.synopsis")) + "\n" +
|
||||
"\r\u0005/env -");
|
||||
|
||||
inputSink.write("\u0003/exit \011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit ");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.exit")) + "\n" +
|
||||
"\r\u0005/exit ");
|
||||
inputSink.write("\011");
|
||||
waitOutput(out, Pattern.quote(getResource("help.exit.summary")) + "\n\n" +
|
||||
Pattern.quote(getResource("jshell.console.see.full.documentation")) + "\n\r\u0005/exit ");
|
||||
inputSink.write("\u0003/doesnotexist\011");
|
||||
waitOutput(out, "\u0005/doesnotexist\n" +
|
||||
Pattern.quote(getResource("jshell.console.no.such.command")) + "\n" +
|
||||
"\n" +
|
||||
"\r\u0005/doesnotexist");
|
||||
});
|
||||
}
|
||||
public class MergedTabShiftTabExpressionTest extends UITesting {
|
||||
|
||||
public void testExpression() throws Exception {
|
||||
Path classes = prepareZip();
|
||||
@ -329,17 +247,4 @@ public class MergedTabShiftTabTest extends UITesting {
|
||||
//where:
|
||||
private final Compiler compiler = new Compiler();
|
||||
|
||||
private final ResourceBundle resources;
|
||||
{
|
||||
resources = ResourceBundle.getBundle("jdk.internal.jshell.tool.resources.l10n", Locale.US, JShell.class.getModule());
|
||||
}
|
||||
|
||||
private String getResource(String key) {
|
||||
return resources.getString(key);
|
||||
}
|
||||
|
||||
private String getMessage(String key, Object... args) {
|
||||
return MessageFormat.format(resources.getString(key), args);
|
||||
}
|
||||
|
||||
}
|
@ -27,13 +27,16 @@ import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Writer;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import jdk.jshell.JShell;
|
||||
import jdk.jshell.tool.JavaShellToolBuilder;
|
||||
|
||||
public class UITesting {
|
||||
@ -168,6 +171,18 @@ public class UITesting {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private final ResourceBundle resources;
|
||||
{
|
||||
resources = ResourceBundle.getBundle("jdk.internal.jshell.tool.resources.l10n", Locale.US, JShell.class.getModule());
|
||||
}
|
||||
|
||||
protected String getResource(String key) {
|
||||
return resources.getString(key);
|
||||
}
|
||||
|
||||
protected String getMessage(String key, Object... args) {
|
||||
return MessageFormat.format(resources.getString(key), args);
|
||||
}
|
||||
private static class PipeInputStream extends InputStream {
|
||||
|
||||
private static final int INITIAL_SIZE = 128;
|
||||
|
Loading…
x
Reference in New Issue
Block a user