Skip to content

Commit

Permalink
Add workaround to solve headless test failure on Windows OS
Browse files Browse the repository at this point in the history
For headless test task, 'prism.order' property is used to choose the
graph renderer to use. Currently, we specify this property to be 'sw'.

However, this property triggers a bug of openjdk-jfx with headless
mode [1]. This property will cause Java Runtime Error for Windows OS
including AppVeyor:

    # A fatal error has been detected by the Java Runtime Environment:
    #
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x00007ffd95b64879, pid=1476, tid=2640
    #
    # JRE version: OpenJDK Runtime Environment (11.0.1+13) (build 11.0.1+13)
    # Java VM: OpenJDK 64-Bit Server VM (11.0.1+13, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
    # Problematic frame:
    # C  [javafx_font.dll+0x4879]

This bug has been identified and will be fixed in future release [2].
There is a workaround suggested which adds static initialization
blocks to load required library before any FxToolkit code [3].

For ui test, the FxToolkit code is firstly used in UiPartRule. For
system test, the FxToolkit code is firstly used in
SystemTestSetupHelper. Let's add the static initialization blocks to
above two classes to solve the problem.

[1] javafxports/openjdk-jfx#66
[2] javafxports/openjdk-jfx#66 (comment)
[3] javafxports/openjdk-jfx#66 (comment)
  • Loading branch information
fzdy1914 committed Apr 11, 2019
1 parent cfa1a0f commit 5e430d0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/test/java/seedu/address/ui/testutil/UiPartRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
public class UiPartRule extends StageRule {
private static final String[] CSS_FILES = {"view/DarkTheme.css", "view/Extensions.css"};

// This is a workaround to solve headless test failure on Windows OS
// Refer to https://github.com/javafxports/openjdk-jfx/issues/66 for more details.
static {
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
System.loadLibrary("WindowsCodecs");
}
}

public void setUiPart(final UiPart<? extends Parent> uiPart) {
try {
FxToolkit.setupScene(() -> {
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/systemtests/SystemTestSetupHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ public class SystemTestSetupHelper {
private TestApp testApp;
private MainWindowHandle mainWindowHandle;

// This is a workaround to solve headless test failure on Windows OS
// Refer to https://github.com/javafxports/openjdk-jfx/issues/66 for more details.
static {
if (System.getProperty("os.name").toLowerCase().startsWith("win")) {
System.loadLibrary("WindowsCodecs");
}
}

/**
* Sets up a new {@code TestApp} and returns it.
*/
Expand Down

0 comments on commit 5e430d0

Please sign in to comment.