Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions .github/scripts/check-surefire-reports.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,34 @@
#!/usr/bin/env bash
# Fails the build if no Tycho Surefire test reports were produced.
# This catches broken test discovery early.
# Fails the build unless every concrete class declaring tests has a Tycho Surefire report.
# This catches a test bundle not packaged as eclipse-test-plugin, a class name Surefire
# does not include, and a module the reactor skipped.
set -euo pipefail

if ! find . -path '*/target/surefire-reports/TEST-*.xml' -print -quit | grep -q .; then
echo "::error::No surefire reports found. Test discovery is likely broken."
test_annotation='^[[:space:]]*@(Test|BugTest|ParameterizedTest|RepeatedTest|TestFactory|TestTemplate)([^[:alnum:]_]|$)'
expected=0
missing=0

while IFS= read -r source; do
if grep -qE 'abstract[[:space:]]+class|@interface' "$source"; then
continue
fi
expected=$((expected + 1))
module=${source%%/*}
class=${source#*/src/}
class=${class%.java}
class=${class//\//.}
if [ ! -f "$module/target/surefire-reports/TEST-$class.xml" ]; then
echo "No surefire report for $source"
missing=$((missing + 1))
fi
done < <(grep -rlE --include='*.java' "$test_annotation" com.avaloq.tools.ddk.*/src)

if [ "$expected" -eq 0 ]; then
echo "::error::No test classes found. This check is likely broken."
exit 1
fi
if [ "$missing" -gt 0 ]; then
echo "::error::$missing of $expected test classes have no surefire report, so they did not run."
exit 1
fi
echo "Found surefire reports for all $expected test classes."
3 changes: 2 additions & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ jobs:
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: test-logs-${{ github.sha }}
path: com.avaloq.tools.ddk.xtext.test/target/work/data/.metadata/.log
path: com.avaloq.tools.ddk.*/target/work/data/.metadata/.log
include-hidden-files: true

- name: Upload p2 update site as artifact
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ jobs:
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
with:
name: tycho-surefire-plugin
path: com.avaloq.tools.ddk.xtext.test/target/work/data/.metadata/.log
path: com.avaloq.tools.ddk.*/target/work/data/.metadata/.log
include-hidden-files: true
19 changes: 10 additions & 9 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ mvnw.cmd clean verify -f ./ddk-parent/pom.xml
## Testing

- **Framework**: JUnit 5 with Tycho Surefire
- **Timeout**: 30 minutes (1800 seconds)
- **Aggregator module**: `com.avaloq.tools.ddk.xtext.test`
- **Timeout**: 30 minutes (1800 seconds) per test module
- **UI tests**: Require virtual display (xvfb on Linux) or `-XstartOnFirstThread` (macOS)

### macOS developer setup
Expand All @@ -90,17 +89,19 @@ therefore need `-XstartOnFirstThread`. There are two contexts:
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
### One JUnit run per test module

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`.
Every test bundle (packaging `eclipse-test-plugin`) runs its own tests in its own Eclipse runtime. `tycho-surefire-plugin` is configured once in `ddk-parent/pom.xml`; individual test poms carry no test configuration. Surefire finds the tests by class name, so there are no test suites to maintain. Fragment test bundles work the same way, with their host in the runtime.

**Consequences for agents:**

- Maven will emit `[INFO] Skipping tests` for every `.test` module except `xtext.test`. This is **correct**, not a bug. Don't "fix" it.
- Flipping `<skip>false</skip>` in another `.test` module will **fail** — those bundles don't carry the tycho-surefire configuration (application, target-platform extras, UI harness) needed to spin up their own test runtime. "Cannot resolve dependencies" is the typical symptom.
- Don't add per-module `tycho-surefire` configuration to individual `.test` poms. To register a new test, either add the test class to an existing `*TestSuite`, or create a new `*TestSuite` class and reference it from `AllTests.java`.
- Why the aggregator design: one Eclipse OSGi runtime startup (~5–10s) instead of N. With ~14 test suites, per-module execution would add ~70–140s of pure startup overhead per run for no functional benefit.
- Non-OSGi pure-POJO tests could theoretically run under plain Maven surefire without Tycho, but most tests depend on Xtext injectors, Eclipse resource APIs, or the UI workbench — so the aggregator is the right choice.
- A new test needs no registration: name the class `*Test`, `*Tests`, `Test*` or `*TestCase`. Classes with other names are not run; CI fails if a concrete class declaring tests has no report (`.github/scripts/check-surefire-reports.sh`).
- A new test bundle needs packaging `eclipse-test-plugin` and an entry in the `ddk-parent/pom.xml` modules list. With packaging `eclipse-plugin` its tests do not run.
- A module's runtime holds only the dependency closure of its manifest. If a test needs a bundle at runtime, for example a language's UI bundle, declare it in that test bundle's `META-INF/MANIFEST.MF`.
- Test classes run in alphabetical order within a module and must not depend on running after other classes.
- With `-T`, test runtimes run one at a time (`reactorConcurrencyLevel` in `ddk-parent/pom.xml`), while everything else stays parallel. `CheckQuickfixTest` failed intermittently on macOS when they overlapped.
- A failed module's tests leave their log in `<module>/target/work/data/.metadata/.log`. CI archives these logs for failed builds.
- To run the tests of one UI bundle from Eclipse, use its launch configuration (e.g. `com.avaloq.tools.ddk.check.ui.test/CheckUiTests.launch`), which runs all tests of the project via JUnit discovery in Eclipse.

## Code Patterns

Expand Down
44 changes: 0 additions & 44 deletions com.avaloq.tools.ddk.check.core.test/CheckCoreTestSuite.launch

This file was deleted.

4 changes: 1 addition & 3 deletions com.avaloq.tools.ddk.check.core.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ Require-Bundle: com.avaloq.tools.ddk.check.core,
org.apache.commons.lang3,
org.eclipse.xtext.xbase.testing,
junit-jupiter-api,
junit-jupiter-engine,
junit-platform-suite-api
junit-jupiter-engine
Export-Package: com.avaloq.tools.ddk.check.core.test,
com.avaloq.tools.ddk.check.core.test.util,
com.avaloq.tools.ddk.check.test.core,
com.avaloq.tools.ddk.check
Import-Package: org.hamcrest.core, org.apache.logging.log4j
Automatic-Module-Name: com.avaloq.tools.ddk.check.core.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.CheckInjectorProvider;
import com.avaloq.tools.ddk.check.core.test.AbstractCheckGenerationTestCase;
import com.avaloq.tools.ddk.check.core.test.util.RegistryIsolatingCheckInjectorProvider;

import static org.junit.jupiter.api.Assertions.assertTrue;

@InjectWith(CheckInjectorProvider.class)
@InjectWith(RegistryIsolatingCheckInjectorProvider.class)
@ExtendWith(InjectionExtension.class)
@SuppressWarnings("nls")
public class IssueCodeValueTest extends AbstractCheckGenerationTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.CheckInjectorProvider;
import com.avaloq.tools.ddk.check.core.test.util.RegistryIsolatingCheckInjectorProvider;
import com.avaloq.tools.ddk.check.runtime.configuration.IModelLocation;
import com.avaloq.tools.ddk.check.runtime.configuration.ModelLocation;
import com.avaloq.tools.ddk.check.scoping.CatalogFromExtensionPointScope;
Expand All @@ -40,9 +40,9 @@
* Some tests for AIG-1314, testing that the CatalogFromExtensionPointScope does not make the resource set grow more than expected.
*/
@ExtendWith(InjectionExtension.class)
@InjectWith(CheckInjectorProvider.class)
@InjectWith(RegistryIsolatingCheckInjectorProvider.class)
@SuppressWarnings("nls")
public class BugAig1314 {
public class BugAig1314Test {

/** Constructor of super class is protected... */
private static class TestScope extends CatalogFromExtensionPointScope {
Expand Down Expand Up @@ -74,7 +74,7 @@ private ModelLocation createModelLocation(final URL url) {
return new ModelLocation(url, TEST_CATALOG_FILE + TEST_CATALOG_EXTENSION) {
@Override
public InputStream getCatalogStream() {
return BugAig1314.class.getResourceAsStream(TEST_CATALOG_FILE);
return BugAig1314Test.class.getResourceAsStream(TEST_CATALOG_FILE);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@InjectWith(CheckUiInjectorProvider.class)
@ExtendWith(InjectionExtension.class)
@SuppressWarnings("nls")
public class BugAig830 {
public class BugAig830Test {

@Inject
private ParseHelper<CheckCatalog> parser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.CheckInjectorProvider;
import com.avaloq.tools.ddk.check.core.test.util.RegistryIsolatingCheckInjectorProvider;


/**
* Tests that the java code generated from BugDsl27 has no errors.
*/
@InjectWith(CheckInjectorProvider.class)
@InjectWith(RegistryIsolatingCheckInjectorProvider.class)
@ExtendWith(InjectionExtension.class)
@SuppressWarnings("nls")
public class BugDsl27 extends AbstractCheckGenerationTestCase {
public class BugDsl27Test extends AbstractCheckGenerationTestCase {

/**
* Tests that our test source compiles fine.
*/
@Test
void testGeneratedCodeHasNoErrors() {
try (InputStream sourceStream = BugDsl27.class.getResourceAsStream("bugdsl27/BugDsl27")) {
try (InputStream sourceStream = BugDsl27Test.class.getResourceAsStream("bugdsl27/BugDsl27")) {
generateAndCompile(sourceStream);
} catch (IOException exception) {
LOGGER.info("Failed to close the test file");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.CheckInjectorProvider;
import com.avaloq.tools.ddk.check.core.test.util.RegistryIsolatingCheckInjectorProvider;
import com.avaloq.tools.ddk.xtext.formatting.LfLineSeparatorInformation;
import com.google.inject.Inject;

Expand All @@ -30,7 +30,7 @@
* runtime modules declare the identical binding method; this test pins the Guice
* module-convention wiring they all rely on.
*/
@InjectWith(CheckInjectorProvider.class)
@InjectWith(RegistryIsolatingCheckInjectorProvider.class)
@ExtendWith(InjectionExtension.class)
@SuppressWarnings("nls")
public class CheckLineSeparatorBindingTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.CheckInjectorProvider;
import com.avaloq.tools.ddk.check.core.test.util.RegistryIsolatingCheckInjectorProvider;


/**
* Unit test for auto generation of check issue code to label map.
*/
@InjectWith(CheckInjectorProvider.class)
@InjectWith(RegistryIsolatingCheckInjectorProvider.class)
@ExtendWith(InjectionExtension.class)
@SuppressWarnings("nls")
public class IssueCodeToLabelMapGenerationTest extends AbstractCheckGenerationTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import com.avaloq.tools.ddk.check.CheckInjectorProvider;
import com.avaloq.tools.ddk.check.core.test.util.RegistryIsolatingCheckInjectorProvider;


/**
* Unit tests for the code generated for the various forms of the {@code issue} expression: markers on a text region, markers on a dynamically
* computed structural feature, and checks declared {@code external}.
*/
@InjectWith(CheckInjectorProvider.class)
@InjectWith(RegistryIsolatingCheckInjectorProvider.class)
@ExtendWith(InjectionExtension.class)
@SuppressWarnings("nls")
public class IssueExpressionGenerationTest extends AbstractCheckGenerationTestCase {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*******************************************************************************
* Copyright (c) 2026 Avaloq Group AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Avaloq Group AG - initial API and implementation
*******************************************************************************/
package com.avaloq.tools.ddk.check.core.test.util;

import org.eclipse.xtext.testing.GlobalRegistries;
import org.eclipse.xtext.testing.GlobalRegistries.GlobalStateMemento;

import com.avaloq.tools.ddk.check.CheckInjectorProvider;


/**
* {@link CheckInjectorProvider} which restores the global EMF registries to their state before each test.
* <p>
* The generated provider restores the state from before its first use instead, which wipes registrations made since by other bundles, e.g. the
* Check validator registered by the Check UI plug-in, and breaks later tests using the UI injector.
*/
public class RegistryIsolatingCheckInjectorProvider extends CheckInjectorProvider {

private GlobalStateMemento stateBeforeTest;

@Override
public void setupRegistry() {
stateBeforeTest = GlobalRegistries.makeCopyOfGlobalState();
super.setupRegistry();
}

@Override
public void restoreRegistry() {
stateBeforeTest.restoreGlobalState();
}

}

This file was deleted.

Loading