Skip to content

Commit

Permalink
8293000: Review running times of jshell regression tests
Browse files Browse the repository at this point in the history
Reviewed-by: darcy
  • Loading branch information
asotona committed Sep 30, 2022
1 parent 6d83482 commit b4e1e41
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
7 changes: 7 additions & 0 deletions test/langtools/jdk/jshell/ClassMembersTest.java
Expand Up @@ -38,12 +38,19 @@
import jdk.jshell.SourceCodeAnalysis;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import jdk.jshell.TypeDeclSnippet;
import static jdk.jshell.Snippet.Status.OVERWRITTEN;
import static jdk.jshell.Snippet.Status.VALID;

public class ClassMembersTest extends KullaTesting {

@BeforeMethod
@Override
public void setUp() {
setUp(builder -> builder.executionEngine("local"));
}

@Test(dataProvider = "memberTestCase")
public void memberTest(AccessModifier accessModifier, CodeChunk codeChunk, Static isStaticMember, Static isStaticReference) {
MemberTestCase testCase = new MemberTestCase(accessModifier, codeChunk, isStaticMember, isStaticReference);
Expand Down
2 changes: 1 addition & 1 deletion test/langtools/jdk/jshell/CompletionSuggestionTest.java
Expand Up @@ -723,7 +723,7 @@ public void testBrokenLambdaCompletion() {

@BeforeMethod
public void setUp() {
super.setUp();
setUp(builder -> builder.executionEngine("local"));

Path srcZip = Paths.get("src.zip");

Expand Down
30 changes: 17 additions & 13 deletions test/langtools/jdk/jshell/ExecutionControlTestBase.java
Expand Up @@ -50,22 +50,30 @@ String standardSpecs() {
}

@Test
public void test() {
variables();
testImportOnDemand();
classesDeclaration();
interfaceTest();
methodOverload();
testExprSanity();
}

public void classesDeclaration() {
assertEval("interface A { }");
assertEval("class B implements A { }");
assertEval("interface C extends A { }");
assertEval("interface AA { }");
assertEval("class BB implements AA { }");
assertEval("interface C extends AA { }");
assertEval("enum D implements C { }");
assertEval("@interface E { }");
assertClasses(
clazz(KullaTesting.ClassType.INTERFACE, "A"),
clazz(KullaTesting.ClassType.CLASS, "B"),
clazz(KullaTesting.ClassType.INTERFACE, "AA"),
clazz(KullaTesting.ClassType.CLASS, "BB"),
clazz(KullaTesting.ClassType.INTERFACE, "C"),
clazz(KullaTesting.ClassType.ENUM, "D"),
clazz(KullaTesting.ClassType.ANNOTATION, "E"));
assertActiveKeys();
}

@Test
public void interfaceTest() {
String interfaceSource
= "interface A {\n"
Expand Down Expand Up @@ -93,7 +101,6 @@ public void interfaceTest() {
assertEval("new B.Inner2();");
}

@Test
public void variables() {
VarSnippet snx = varKey(assertEval("int x = 10;"));
VarSnippet sny = varKey(assertEval("String y = \"hi\";"));
Expand All @@ -105,7 +112,6 @@ public void variables() {
assertActiveKeys();
}

@Test
public void methodOverload() {
assertEval("int m() { return 1; }");
assertEval("int m(int x) { return 2; }");
Expand All @@ -130,15 +136,13 @@ public void methodOverload() {
assertActiveKeys();
}

@Test
public void testExprSanity() {
assertEval("int x = 3;", "3");
assertEval("int y = 4;", "4");
assertEval("x + y;", "7");
assertEval("int i = 3;", "3");
assertEval("int j = 4;", "4");
assertEval("i + j;", "7");
assertActiveKeys();
}

@Test
public void testImportOnDemand() {
assertImportKeyMatch("import java.util.*;", "java.util.*", TYPE_IMPORT_ON_DEMAND_SUBKIND, added(VALID));
assertEval("List<Integer> list = new ArrayList<>();");
Expand Down
7 changes: 7 additions & 0 deletions test/langtools/jdk/jshell/SimpleRegressionTest.java
Expand Up @@ -44,10 +44,17 @@
import static jdk.jshell.Snippet.Status.OVERWRITTEN;
import static jdk.jshell.Snippet.SubKind.TEMP_VAR_EXPRESSION_SUBKIND;
import static jdk.jshell.Snippet.Status.VALID;
import org.testng.annotations.BeforeMethod;

@Test
public class SimpleRegressionTest extends KullaTesting {

@BeforeMethod
@Override
public void setUp() {
setUp(builder -> builder.executionEngine("local"));
}

public void testSnippetMemberAssignment() {
assertEval("class C { int y; }");
assertEval("C c = new C();");
Expand Down
5 changes: 0 additions & 5 deletions test/langtools/jdk/jshell/ToolBasicTest.java
Expand Up @@ -155,11 +155,6 @@ private void assertStop(boolean after, String cmd, String output) {
out = new PrintWriter(writer);
setCommandInput(cmd + "\n");
t = new Thread(() -> {
try {
// no chance to know whether cmd is being evaluated
Thread.sleep(5000);
} catch (InterruptedException ignored) {
}
int i = 1;
int n = 30;
synchronized (lock) {
Expand Down

0 comments on commit b4e1e41

Please sign in to comment.