Skip to content

Commit a7923b1

Browse files
author
rfield
committed
8139872: JShell tests: EditorPadTest failing on headless
Reviewed-by: vromero
1 parent a90e112 commit a7923b1

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

langtools/test/jdk/jshell/EditorPadTest.java

+21-9
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323

2424
/*
2525
* @test
26+
* @bug 8139872
2627
* @summary Testing built-in editor.
27-
* @ignore 8139872
28-
* @modules jdk.jshell/jdk.internal.jshell.tool
28+
* @modules java.desktop/java.awt
29+
* jdk.jshell/jdk.internal.jshell.tool
2930
* @build ReplToolTesting EditorTestBase
3031
* @run testng EditorPadTest
3132
*/
@@ -35,6 +36,7 @@
3536
import java.awt.Container;
3637
import java.awt.Dimension;
3738
import java.awt.Frame;
39+
import java.awt.GraphicsEnvironment;
3840
import java.awt.Point;
3941
import java.awt.Robot;
4042
import java.awt.event.InputEvent;
@@ -67,14 +69,24 @@ public class EditorPadTest extends EditorTestBase {
6769
private static JButton accept = null;
6870
private static JButton exit = null;
6971

72+
// Do not actually run if we are headless
73+
@Override
74+
public void testEditor(boolean defaultStartup, String[] args, ReplTest... tests) {
75+
if (!GraphicsEnvironment.isHeadless()) {
76+
test(defaultStartup, args, tests);
77+
}
78+
}
79+
7080
@BeforeClass
7181
public static void setUpEditorPadTest() {
72-
try {
73-
robot = new Robot();
74-
robot.setAutoWaitForIdle(true);
75-
robot.setAutoDelay(DELAY);
76-
} catch (AWTException e) {
77-
throw new ExceptionInInitializerError(e);
82+
if (!GraphicsEnvironment.isHeadless()) {
83+
try {
84+
robot = new Robot();
85+
robot.setAutoWaitForIdle(true);
86+
robot.setAutoDelay(DELAY);
87+
} catch (AWTException e) {
88+
throw new ExceptionInInitializerError(e);
89+
}
7890
}
7991
}
8092

@@ -123,7 +135,7 @@ public void shutdownEditor() {
123135
@Test
124136
public void testShuttingDown() {
125137
testEditor(
126-
(a) -> assertEditOutput(a, "/e", "", this::shutdownEditor)
138+
(a) -> assertEditOutput(a, "/ed", "", this::shutdownEditor)
127139
);
128140
}
129141

langtools/test/jdk/jshell/EditorTestBase.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,9 @@ public void testEditNegative() {
7373
for (String edit : new String[] {"/ed", "/edit"}) {
7474
test(new String[]{"-nostartup"},
7575
a -> assertCommandOutputStartsWith(a, edit + " 1",
76-
"| No definition or id found named: 1"),
77-
a -> assertCommandOutputStartsWith(a, edit + " -1",
78-
"| No definition or id found named: -1"),
76+
"| No such snippet: 1"),
7977
a -> assertCommandOutputStartsWith(a, edit + " unknown",
80-
"| No definition or id found named: unknown")
78+
"| No such snippet: unknown")
8179
);
8280
}
8381
}

0 commit comments

Comments
 (0)