From 4773ae89670e30416a1af2380c35bce9309df6a1 Mon Sep 17 00:00:00 2001 From: WANG CHAO <1229983126@qq.com> Date: Thu, 21 Mar 2019 21:53:10 +0800 Subject: [PATCH] Workaround headless test failure on Windows OS 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] https://github.com/javafxports/openjdk-jfx/issues/66 [2] https://github.com/javafxports/openjdk-jfx/issues/66#issuecomment-472693380 [3] https://github.com/javafxports/openjdk-jfx/issues/66#issuecomment-468370664 [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 --- src/test/java/seedu/address/ui/GuiUnitTest.java | 9 +++++++++ src/test/java/systemtests/AddressBookSystemTest.java | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/test/java/seedu/address/ui/GuiUnitTest.java b/src/test/java/seedu/address/ui/GuiUnitTest.java index aefb6ac9073..3c49536fe7c 100644 --- a/src/test/java/seedu/address/ui/GuiUnitTest.java +++ b/src/test/java/seedu/address/ui/GuiUnitTest.java @@ -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"); + } + } + @RegisterExtension public final UiPartExtension uiPartExtension = new UiPartExtension(); diff --git a/src/test/java/systemtests/AddressBookSystemTest.java b/src/test/java/systemtests/AddressBookSystemTest.java index 926659f53af..7877c065a75 100644 --- a/src/test/java/systemtests/AddressBookSystemTest.java +++ b/src/test/java/systemtests/AddressBookSystemTest.java @@ -46,6 +46,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"); + } + } + @RegisterExtension public static ClockExtension clockExtension = new ClockExtension();