Run tests that checks araxis output only on Linux

Bug: 580189
Change-Id: Ieb14f5cf061fcb468b602c7f27e27b672e3b09e2
Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
This commit is contained in:
Simeon Andreev 2022-06-17 12:19:50 +02:00 committed by Matthias Sohn
parent 2adbd74387
commit 0c32889ebc
4 changed files with 28 additions and 0 deletions

View File

@ -81,6 +81,8 @@ public void testUserToolWithCommandNotFoundError() throws Exception {
@Test(expected = Die.class)
public void testEmptyToolName() throws Exception {
assumeLinuxPlatform();
String emptyToolName = "";
StoredConfig config = db.getConfig();

View File

@ -79,6 +79,8 @@ public void testUserToolWithCommandNotFoundError() throws Exception {
@Test
public void testEmptyToolName() throws Exception {
assumeLinuxPlatform();
String emptyToolName = "";
StoredConfig config = db.getConfig();

View File

@ -32,6 +32,8 @@
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.treewalk.FileTreeIterator;
import org.eclipse.jgit.treewalk.TreeWalk;
import org.eclipse.jgit.util.SystemReader;
import org.junit.Assume;
import org.junit.Before;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
@ -240,4 +242,9 @@ protected static void assertArrayOfMatchingLines(String failMessage,
matches);
}
}
protected static void assumeLinuxPlatform() {
Assume.assumeTrue("This test can run only in Linux tests",
SystemReader.getInstance().isLinux());
}
}

View File

@ -63,6 +63,8 @@ public abstract class SystemReader {
private static volatile Boolean isWindows;
private static volatile Boolean isLinux;
static {
SystemReader r = new Default();
r.init();
@ -185,6 +187,7 @@ public static SystemReader getInstance() {
public static void setInstance(SystemReader newReader) {
isMacOS = null;
isWindows = null;
isLinux = null;
if (newReader == null)
INSTANCE = DEFAULT;
else {
@ -543,6 +546,20 @@ public boolean isMacOS() {
return isMacOS.booleanValue();
}
/**
* Whether we are running on Linux.
*
* @return true if we are running on Linux.
* @since 6.3
*/
public boolean isLinux() {
if (isLinux == null) {
String osname = getOsName();
isLinux = Boolean.valueOf(osname.toLowerCase().startsWith("linux")); //$NON-NLS-1$
}
return isLinux.booleanValue();
}
private String getOsName() {
return AccessController.doPrivileged(
(PrivilegedAction<String>) () -> getProperty("os.name") //$NON-NLS-1$