Skip to content

Commit 6ea2570

Browse files
committed
Adding more info on container startup in the wrapper
1 parent d18f85e commit 6ea2570

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

JShellWrapper/src/main/java/JShellWrapper.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ public void run(Config config, InputStream in, PrintStream processOut) {
1818
String startup = desanitize(processIn.nextLine());
1919
StringOutputStream jshellOut = new StringOutputStream(config.sysOutCharLimit());
2020
try (JShell shell = JShell.builder().out(new PrintStream(jshellOut)).build()) {
21-
verifyStartupEval(eval(shell, startup, new AtomicBoolean()));
21+
EvalResult startupEval = eval(shell, startup, new AtomicBoolean());
22+
verifyStartupEval(startupEval);
23+
ok(processOut);
24+
processOut.println(startupEval.events().size());
25+
processOut.flush();
2226
while(true) {
2327
String command = processIn.nextLine();
2428
switch (command) {

JShellWrapper/src/test/java/JShellWrapperStartupScriptTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ void testDoubleSnippets() {
1919
JShellWrapper jshell = new JShellWrapper();
2020
jshell.run(config, inputStream, new PrintStream(outputStream));
2121
assertEquals("""
22+
OK
23+
2
2224
OK
2325
1
2426
VALID

JShellWrapper/src/test/java/JShellWrapperTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ void testHelloWorld() {
2929
System.out.println("Hello world!")""",
3030
"""
3131
OK
32+
0
33+
OK
3234
1
3335
VALID
3436
ADDITION
@@ -50,6 +52,8 @@ void testMultilinesInput() {
5052
System.out.println();""",
5153
"""
5254
OK
55+
0
56+
OK
5357
2
5458
VALID
5559
ADDITION
@@ -73,6 +77,8 @@ void testStdoutOverflow() {
7377
for(int i = 0; i < 1024; i++) System.out.print(0)""",
7478
"""
7579
OK
80+
0
81+
OK
7682
1
7783
VALID
7884
ADDITION
@@ -88,6 +94,8 @@ void testStdoutOverflow() {
8894
for(int i = 0; i <= 1024; i++) System.out.print(0)""",
8995
"""
9096
OK
97+
0
98+
OK
9199
1
92100
VALID
93101
ADDITION
@@ -107,6 +115,8 @@ void testModificationAndMultiplesSnippets() {
107115
int i = 2;""",
108116
"""
109117
OK
118+
0
119+
OK
110120
2
111121
VALID
112122
ADDITION
@@ -130,6 +140,8 @@ void testUseId() {
130140
System.out.println("Hello world!")""",
131141
"""
132142
OK
143+
0
144+
OK
133145
1
134146
VALID
135147
ADDITION
@@ -148,6 +160,8 @@ void testTimeout() {
148160
while(true);""",
149161
"""
150162
OK
163+
0
164+
OK
151165
1
152166
VALID
153167
ADDITION
@@ -168,6 +182,8 @@ void testUncaughtException() {// TODO other kind of exception, not in EvalExcept
168182
throw new RuntimeException("Some message : fail")""",
169183
"""
170184
OK
185+
0
186+
OK
171187
1
172188
VALID
173189
ADDITION
@@ -188,6 +204,8 @@ void testRejected() {
188204
1
189205
print""",
190206
"""
207+
OK
208+
0
191209
OK
192210
1
193211
REJECTED
@@ -213,6 +231,8 @@ void testSyntaxError() {
213231
"""
214232
OK
215233
0
234+
OK
235+
0
216236
SYNTAX_ERROR
217237
print(
218238
@@ -226,6 +246,8 @@ void testSyntaxError() {
226246
"""
227247
OK
228248
0
249+
OK
250+
0
229251
SYNTAX_ERROR
230252
while(true)
231253
@@ -238,6 +260,8 @@ void testSyntaxError() {
238260
"""
239261
OK
240262
0
263+
OK
264+
0
241265
SYNTAX_ERROR
242266
for(int i = 0; i < 10; i++)
243267
@@ -253,6 +277,8 @@ void testRejectedAndMultiples() {
253277
print;
254278
System.out.println(i);""",
255279
"""
280+
OK
281+
0
256282
OK
257283
2
258284
VALID
@@ -283,6 +309,8 @@ void testMultilinesAndHardcodedNewLineInString() {
283309
}""",
284310
"""
285311
OK
312+
0
313+
OK
286314
1
287315
VALID
288316
ADDITION

0 commit comments

Comments
 (0)