From 0b7a7ccc376ae1d2b9a4b64de2d620c09ebd6e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Dinis=20Ferreira?= Date: Sat, 7 Mar 2026 09:35:01 +0100 Subject: [PATCH] build: enable UI tests on macOS via Tycho profile + JRE docs Add a `macosx` Maven profile in ddk-parent/pom.xml, activated on family=mac, that sets the OSGi target environment (macosx/cocoa/aarch64) and appends -XstartOnFirstThread to test.javaOptions. SWT on Cocoa requires the Display to be created on the main thread; without the flag, UI tests fail with "SWTException: Invalid thread access". The same flag is needed when developers run UI test launches from Eclipse on macOS, but -XstartOnFirstThread is rejected as an "Unrecognized VM option" by the JVM on Windows and Linux. Eclipse's own .launch files (e.g. in eclipse-platform/eclipse.platform) omit it entirely and rely on the launching JRE's default VM arguments to add it on macOS. Adopt the same pattern: document the one-time per-JRE setup in AGENTS.md instead of hardcoding the flag in cross-platform .launch files. Co-Authored-By: Claude Opus 4.7 --- AGENTS.md | 15 +++++++++++++++ ddk-parent/pom.xml | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 77ea18a9d4..6fe4580db4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -68,6 +68,21 @@ export WORKSPACE=$(pwd) - **Aggregator module**: `com.avaloq.tools.ddk.xtext.test` - **UI tests**: Require virtual display (xvfb on Linux) or `-XstartOnFirstThread` (macOS) +### macOS developer setup + +SWT on Cocoa requires the Display to be created on the main thread. UI tests +therefore need `-XstartOnFirstThread`. There are two contexts: + +- **`mvn verify` / CI**: the `macosx` profile in `ddk-parent/pom.xml` (activated + on `family=mac`) adds the flag automatically. No setup required. +- **Running launches from Eclipse**: add `-XstartOnFirstThread` to your JRE's + default VM arguments — `Window > Preferences > Java > Installed JREs > [your + JDK] > Edit > Default VM arguments`. PDE launches with `append.args=true` + inherit this on macOS only. The flag is not hardcoded in the `.launch` files + because the JVM on Windows and Linux rejects it as an "Unrecognized VM + option". This matches Eclipse Platform's own UI test launches (which omit + the flag and rely on the same JRE-default-args mechanism). + ### Aggregator pattern — important The project runs **all tests through one aggregator module**, not per-`.test`-module. `ddk-parent/pom.xml` sets `true` on `tycho-surefire-plugin` globally; only `com.avaloq.tools.ddk.xtext.test` overrides it with its own full tycho-surefire configuration. Inside that module, `src/com/avaloq/tools/ddk/xtext/AllTests.java` is a JUnit 5 `@Suite` that `@SelectClasses` from ~14 per-module `*TestSuite` classes (`ExportTestSuite`, `CheckCoreTestSuite`, `TypeSystemTestSuite`, `CheckUiTestSuite`, etc.). Those other `.test` bundles are on `xtext.test`'s OSGi classpath via `Require-Bundle`, so their test classes get discovered and executed inside the single Eclipse runtime spun up for `xtext.test`. diff --git a/ddk-parent/pom.xml b/ddk-parent/pom.xml index a32edb44c7..2f0db41189 100644 --- a/ddk-parent/pom.xml +++ b/ddk-parent/pom.xml @@ -425,5 +425,19 @@ x86_64 + + macosx + + + mac + + + + macosx + cocoa + aarch64 + ${runtime.javaOptions} -XstartOnFirstThread + +