Skip to content

Commit

Permalink
Convert equinox.launcher.tests into a test-fragment
Browse files Browse the repository at this point in the history
This fixes the following shortcomings associated to the launcher tests.

- When building the native launcher and executable, the entire test
project was also copied to the specialized build agents, which
unnecessarily increases their network-traffic.

- Test cannot be executed (as JUnit-Plugin test) in the IDE without
further setup.

- Setting up tests and patching a local developer eclipse should not be
done in a make-file. Its complexity should not be increased by such
task, that also only work with simple installations but not distributed
ones.
  • Loading branch information
HannesWell committed Apr 8, 2024
1 parent f289d49 commit 825c69f
Show file tree
Hide file tree
Showing 21 changed files with 244 additions and 286 deletions.
25 changes: 16 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ jobs:

build-launcher:
name: Build launcher ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
runs-on: ${{ matrix.config.runner-os }}
strategy:
fail-fast: false
matrix:
config:
- { name: Linux, os: ubuntu-latest, ws: gtk, native-extension: so }
- { name: Windows, os: windows-2019, ws: win32, native-extension: dll }
- { name: MacOS, os: macos-latest, ws: cocoa, native-extension: so }
- { name: Linux, runner-os: ubuntu-latest, ws: gtk, os: linux, native-extension: so }
- { name: Windows, runner-os: windows-2019, ws: win32, os: win32, native-extension: dll }
- { name: MacOS, runner-os: macos-latest, ws: cocoa, os: macosx, native-extension: so }
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -87,21 +87,28 @@ jobs:
if: ${{ matrix.config.ws == 'gtk'}}
- name: Build on POSIX
working-directory: features/org.eclipse.equinox.executable.feature/library/${{ matrix.config.ws }}
run: ./build.sh test
env:
BINARIES_DIR: ${{ github.workspace }}/equinox.binaries
run: ./build.sh -ws ${{ matrix.config.ws }} -os ${{ matrix.config.os }} -arch x86_64 install
if: ${{ matrix.config.ws != 'win32'}}
- name: Build on Windows
working-directory: features/org.eclipse.equinox.executable.feature/library/win32
run: .\build.bat test
env:
BINARIES_DIR: ${{ github.workspace }}\equinox.binaries
run: .\build.bat -ws win32 -os win32 -arch x86_64 install
if: ${{ matrix.config.ws == 'win32'}}
- name: Test native launcher and executable
env:
EQUINOX_BINARIES_LOC: ${{ github.workspace }}/equinox.binaries
run: mvn -B -pl org.eclipse.equinox:org.eclipse.equinox.launcher.tests -am verify
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: success()
with:
name: ${{ matrix.config.name }} launcher artifacts
path: |
features/org.eclipse.equinox.executable.feature/library/${{ matrix.config.ws }}/eclipse
features/org.eclipse.equinox.executable.feature/library/${{ matrix.config.ws }}/eclipse*.exe
features/org.eclipse.equinox.executable.feature/library/${{ matrix.config.ws }}/eclipse*.${{ matrix.config.native-extension }}
equinox.binaries/org.eclipse.equinox.executable/bin/${{ matrix.config.ws }}/${{ matrix.config.os }}/x86_64/**/eclipse*
equinox.binaries/org.eclipse.equinox.launcher.${{ matrix.config.ws }}.${{ matrix.config.os }}.x86_64/eclipse_*.${{ matrix.config.native-extension }}
if-no-files-found: error
- name: Upload ${{ matrix.config.name }} Test Results
uses: actions/upload-artifact@v4
Expand Down
3 changes: 3 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pipeline {
maven 'apache-maven-latest'
jdk 'temurin-jdk17-latest'
}
environment {
EQUINOX_BINARIES_LOC = "$WORKSPACE/rt.equinox.binaries"
}
stages {
stage('get binaries') {
steps{
Expand Down
15 changes: 15 additions & 0 deletions bundles/org.eclipse.equinox.launcher.tests/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.launcher.tests</name>
<name>org.eclipse.equinox.launcher.tests</name>
<comment></comment>
<projects>
</projects>
Expand All @@ -11,13 +11,18 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
10 changes: 10 additions & 0 deletions bundles/org.eclipse.equinox.launcher.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests
Bundle-SymbolicName: org.eclipse.equinox.launcher.tests
Bundle-Version: 1.0.0.qualifier
Fragment-Host: org.eclipse.equinox.launcher
Automatic-Module-Name: org.eclipse.launcher.tests
Bundle-RequiredExecutionEnvironment: JavaSE-17
Import-Package: org.junit.jupiter.api;version="[5.10.0,6.0.0)",
org.junit.jupiter.api.io;version="[5.10.0,6.0.0)"
4 changes: 4 additions & 0 deletions bundles/org.eclipse.equinox.launcher.tests/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2023 Eclipse Foundation, Inc. and others.
* Copyright (c) 2023, 2024 Eclipse Foundation, Inc. and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -39,6 +39,13 @@
*/
public class TestLauncherApp {

public static final String ARGS_PARAMETER = "-args"; //$NON-NLS-1$
public static final String EXITDATA_PARAMETER = "-exitdata"; //$NON-NLS-1$
public static final String EXITCODE_PARAMETER = "-exitcode"; //$NON-NLS-1$
public static final String MULTILINE_ARG_VALUE_TERMINATOR = "---"; //$NON-NLS-1$

public static final String PORT_ENV_KEY = "eclipse_test_port"; //$NON-NLS-1$

private static JNIBridge bridge;
private static String sharedId;
private static String[] args;
Expand Down Expand Up @@ -84,25 +91,25 @@ private static void parseArgs(String[] args) {
}

private static void communicateToServer() throws Exception {
String port = System.getenv(TestLauncherConstants.PORT_ENV_KEY);
String port = System.getenv(PORT_ENV_KEY);
try (Socket socket = new Socket()) {
socket.connect(new InetSocketAddress("localhost", Integer.parseInt(port)), 10000);
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
DataOutputStream out = new DataOutputStream(socket.getOutputStream());
String line;
while ((line = in.readLine()) != null) {
if (TestLauncherConstants.ARGS_PARAMETER.equals(line)) {
out.writeBytes(String.join("\n", args) + "\n" + TestLauncherConstants.MULTILINE_ARG_VALUE_TERMINATOR + "\n");
if (ARGS_PARAMETER.equals(line)) {
out.writeBytes(String.join("\n", args) + "\n" + MULTILINE_ARG_VALUE_TERMINATOR + "\n");
out.flush();
} else if (TestLauncherConstants.EXITDATA_PARAMETER.equals(line)) {
} else if (EXITDATA_PARAMETER.equals(line)) {
while ((line = in.readLine()) != null) {
if (TestLauncherConstants.MULTILINE_ARG_VALUE_TERMINATOR.equals(line)) {
if (MULTILINE_ARG_VALUE_TERMINATOR.equals(line)) {
break;
}
exitData.add(line);
}
} else if (TestLauncherConstants.EXITCODE_PARAMETER.equals(line)) {
TestLauncherApp.exitCode = Integer.parseInt(in.readLine());
} else if (EXITCODE_PARAMETER.equals(line)) {
exitCode = Integer.parseInt(in.readLine());
break;
}
}
Expand Down

0 comments on commit 825c69f

Please sign in to comment.