Skip to content

Commit 940596f

Browse files
joaodinissfclaude
andcommitted
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 <noreply@anthropic.com>
1 parent 11c352b commit 940596f

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ export WORKSPACE=$(pwd)
6868
- **Aggregator module**: `com.avaloq.tools.ddk.xtext.test`
6969
- **UI tests**: Require virtual display (xvfb on Linux) or `-XstartOnFirstThread` (macOS)
7070

71+
### macOS developer setup
72+
73+
SWT on Cocoa requires the Display to be created on the main thread. UI tests
74+
therefore need `-XstartOnFirstThread`. There are two contexts:
75+
76+
- **`mvn verify` / CI**: the `macosx` profile in `ddk-parent/pom.xml` (activated
77+
on `family=mac`) adds the flag automatically. No setup required.
78+
- **Running launches from Eclipse**: add `-XstartOnFirstThread` to your JRE's
79+
default VM arguments — `Window > Preferences > Java > Installed JREs > [your
80+
JDK] > Edit > Default VM arguments`. PDE launches with `append.args=true`
81+
inherit this on macOS only. The flag is not hardcoded in the `.launch` files
82+
because the JVM on Windows and Linux rejects it as an "Unrecognized VM
83+
option". This matches Eclipse Platform's own UI test launches (which omit
84+
the flag and rely on the same JRE-default-args mechanism).
85+
7186
### Aggregator pattern — important
7287

7388
The project runs **all tests through one aggregator module**, not per-`.test`-module. `ddk-parent/pom.xml` sets `<skip>true</skip>` 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`.

ddk-parent/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,5 +411,19 @@
411411
<osgi.arch>x86_64</osgi.arch>
412412
</properties>
413413
</profile>
414+
<profile>
415+
<id>macosx</id>
416+
<activation>
417+
<os>
418+
<family>mac</family>
419+
</os>
420+
</activation>
421+
<properties>
422+
<osgi.os>macosx</osgi.os>
423+
<osgi.ws>cocoa</osgi.ws>
424+
<osgi.arch>aarch64</osgi.arch>
425+
<test.javaOptions>${runtime.javaOptions} -XstartOnFirstThread</test.javaOptions>
426+
</properties>
427+
</profile>
414428
</profiles>
415429
</project>

0 commit comments

Comments
 (0)