Skip to content

Commit 349cbb6

Browse files
asotonaRealCLanger
authored andcommitted
8293000: Review running times of jshell regression tests
Backport-of: b4e1e416dacb6099a780f2250cef737834c19d56
1 parent 2c0fd68 commit 349cbb6

File tree

5 files changed

+32
-19
lines changed

5 files changed

+32
-19
lines changed

test/langtools/jdk/jshell/ClassMembersTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,19 @@
3838
import jdk.jshell.SourceCodeAnalysis;
3939
import org.testng.annotations.DataProvider;
4040
import org.testng.annotations.Test;
41+
import org.testng.annotations.BeforeMethod;
4142
import jdk.jshell.TypeDeclSnippet;
4243
import static jdk.jshell.Snippet.Status.OVERWRITTEN;
4344
import static jdk.jshell.Snippet.Status.VALID;
4445

4546
public class ClassMembersTest extends KullaTesting {
4647

48+
@BeforeMethod
49+
@Override
50+
public void setUp() {
51+
setUp(builder -> builder.executionEngine("local"));
52+
}
53+
4754
@Test(dataProvider = "memberTestCase")
4855
public void memberTest(AccessModifier accessModifier, CodeChunk codeChunk, Static isStaticMember, Static isStaticReference) {
4956
MemberTestCase testCase = new MemberTestCase(accessModifier, codeChunk, isStaticMember, isStaticReference);

test/langtools/jdk/jshell/CompletionSuggestionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public void testBrokenLambdaCompletion() {
721721

722722
@BeforeMethod
723723
public void setUp() {
724-
super.setUp();
724+
setUp(builder -> builder.executionEngine("local"));
725725

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

test/langtools/jdk/jshell/ExecutionControlTestBase.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,30 @@ String standardSpecs() {
5050
}
5151

5252
@Test
53+
public void test() {
54+
variables();
55+
testImportOnDemand();
56+
classesDeclaration();
57+
interfaceTest();
58+
methodOverload();
59+
testExprSanity();
60+
}
61+
5362
public void classesDeclaration() {
54-
assertEval("interface A { }");
55-
assertEval("class B implements A { }");
56-
assertEval("interface C extends A { }");
63+
assertEval("interface AA { }");
64+
assertEval("class BB implements AA { }");
65+
assertEval("interface C extends AA { }");
5766
assertEval("enum D implements C { }");
5867
assertEval("@interface E { }");
5968
assertClasses(
60-
clazz(KullaTesting.ClassType.INTERFACE, "A"),
61-
clazz(KullaTesting.ClassType.CLASS, "B"),
69+
clazz(KullaTesting.ClassType.INTERFACE, "AA"),
70+
clazz(KullaTesting.ClassType.CLASS, "BB"),
6271
clazz(KullaTesting.ClassType.INTERFACE, "C"),
6372
clazz(KullaTesting.ClassType.ENUM, "D"),
6473
clazz(KullaTesting.ClassType.ANNOTATION, "E"));
6574
assertActiveKeys();
6675
}
6776

68-
@Test
6977
public void interfaceTest() {
7078
String interfaceSource
7179
= "interface A {\n"
@@ -93,7 +101,6 @@ public void interfaceTest() {
93101
assertEval("new B.Inner2();");
94102
}
95103

96-
@Test
97104
public void variables() {
98105
VarSnippet snx = varKey(assertEval("int x = 10;"));
99106
VarSnippet sny = varKey(assertEval("String y = \"hi\";"));
@@ -105,7 +112,6 @@ public void variables() {
105112
assertActiveKeys();
106113
}
107114

108-
@Test
109115
public void methodOverload() {
110116
assertEval("int m() { return 1; }");
111117
assertEval("int m(int x) { return 2; }");
@@ -130,15 +136,13 @@ public void methodOverload() {
130136
assertActiveKeys();
131137
}
132138

133-
@Test
134139
public void testExprSanity() {
135-
assertEval("int x = 3;", "3");
136-
assertEval("int y = 4;", "4");
137-
assertEval("x + y;", "7");
140+
assertEval("int i = 3;", "3");
141+
assertEval("int j = 4;", "4");
142+
assertEval("i + j;", "7");
138143
assertActiveKeys();
139144
}
140145

141-
@Test
142146
public void testImportOnDemand() {
143147
assertImportKeyMatch("import java.util.*;", "java.util.*", TYPE_IMPORT_ON_DEMAND_SUBKIND, added(VALID));
144148
assertEval("List<Integer> list = new ArrayList<>();");

test/langtools/jdk/jshell/SimpleRegressionTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,17 @@
4444
import static jdk.jshell.Snippet.Status.OVERWRITTEN;
4545
import static jdk.jshell.Snippet.SubKind.TEMP_VAR_EXPRESSION_SUBKIND;
4646
import static jdk.jshell.Snippet.Status.VALID;
47+
import org.testng.annotations.BeforeMethod;
4748

4849
@Test
4950
public class SimpleRegressionTest extends KullaTesting {
5051

52+
@BeforeMethod
53+
@Override
54+
public void setUp() {
55+
setUp(builder -> builder.executionEngine("local"));
56+
}
57+
5158
public void testSnippetMemberAssignment() {
5259
assertEval("class C { int y; }");
5360
assertEval("C c = new C();");

test/langtools/jdk/jshell/ToolBasicTest.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ private void assertStop(boolean after, String cmd, String output) {
155155
out = new PrintWriter(writer);
156156
setCommandInput(cmd + "\n");
157157
t = new Thread(() -> {
158-
try {
159-
// no chance to know whether cmd is being evaluated
160-
Thread.sleep(5000);
161-
} catch (InterruptedException ignored) {
162-
}
163158
int i = 1;
164159
int n = 30;
165160
synchronized (lock) {

0 commit comments

Comments
 (0)