-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Remove OS-specific setting from unit tests - Use GitHub actions to run tests on several platforms Signed-off-by: Martin Fleck <[email protected]>
- Loading branch information
1 parent
e6d281e
commit 7fd26f2
Showing
6 changed files
with
155 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build-m2: | ||
strategy: | ||
# do not cancel other builds if one fails | ||
fail-fast: false | ||
matrix: | ||
os: [windows-2019, ubuntu-18.04, macos-10.15] | ||
|
||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Build with Maven | ||
run: mvn -B -Pm2 clean verify --file pom.xml | ||
|
||
build-p2: | ||
strategy: | ||
# do not cancel other builds if one fails | ||
fail-fast: false | ||
matrix: | ||
os: [windows-2019, ubuntu-18.04, macos-10.15] | ||
|
||
runs-on: ${{ matrix.os }} | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Build with Maven | ||
run: mvn -B -Pp2 clean verify --file pom.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
...se.emfcloud.modelserver.tests/src/org/eclipse/emfcloud/modelserver/tests/util/OSUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021 EclipseSource and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0, or the MIT License which is | ||
* available at https://opensource.org/licenses/MIT. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR MIT | ||
********************************************************************************/ | ||
package org.eclipse.emfcloud.modelserver.tests.util; | ||
|
||
import static org.hamcrest.CoreMatchers.endsWith; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
import java.io.File; | ||
|
||
import org.hamcrest.Matcher; | ||
|
||
public final class OSUtil { | ||
private static String OS_NAME = System.getProperty("os.name", "unknown").toLowerCase(); | ||
|
||
private OSUtil() {} | ||
|
||
public static boolean isWindows() { return OS_NAME.contains("win"); } | ||
|
||
public static boolean isMac() { return OS_NAME.contains("mac"); } | ||
|
||
public static boolean isUnix() { | ||
return OS_NAME.contains("nux") || OS_NAME.contains("nix") || OS_NAME.contains("aix"); | ||
} | ||
|
||
public static String osLineSeparator(final String text) { | ||
// assume linux by default | ||
return isWindows() | ||
? text.replaceAll("\\n", System.lineSeparator()) | ||
: text; | ||
} | ||
|
||
public static String osFileSeparator(final String text) { | ||
return isWindows() | ||
? text.replace("/", File.separator) | ||
: text; | ||
} | ||
|
||
public static Matcher<String> osEndsWith(final String suffix) { | ||
return endsWith(osFileSeparator(suffix)); | ||
} | ||
|
||
public static Matcher<String> osIs(final String text) { | ||
return is(osFileSeparator(text)); | ||
} | ||
} |