Skip to content

Commit

Permalink
Workaround 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].

Java will initialize base classes first before classes of instance
members [4] [5]. For all GUI tests, they uses GuiUnitTest or
AddressBookSystemTest as their base class. Let's add the static
initialization blocks to these two classes to solve the problem.

[1] javafxports/openjdk-jfx#66
[2] javafxports/openjdk-jfx#66 (comment)
[3] javafxports/openjdk-jfx#66 (comment)
[4] https://docs.oracle.com/javase/specs/jls/se8/html/jls-12.html#jls-12.4
[5] https://docs.oracle.com/javase/specs/jls/se8/html/jls-12.html#jls-12.5
  • Loading branch information
fzdy1914 committed Apr 23, 2019
1 parent 06a73fe commit 06b7e76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/java/seedu/address/ui/GuiUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
* A GUI unit test class for AddressBook.
*/
public abstract class GuiUnitTest {
// TODO: Remove this workaround after using JavaFX version 13 or above
// 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");
}
}

@Rule
public final UiPartRule uiPartRule = new UiPartRule();

Expand Down
9 changes: 9 additions & 0 deletions src/test/java/systemtests/AddressBookSystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@
* for test verification.
*/
public abstract class AddressBookSystemTest {
// TODO: Remove this workaround after using JavaFX version 13 or above
// 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");
}
}

@ClassRule
public static ClockRule clockRule = new ClockRule();

Expand Down

0 comments on commit 06b7e76

Please sign in to comment.