Skip to content

Commit

Permalink
Add Windows ARM platform, rename other platforms to include arch
Browse files Browse the repository at this point in the history
  • Loading branch information
alexh-sauce committed Oct 24, 2024
1 parent 510dec3 commit fe7ca48
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,46 @@ public class SauceConnectManager extends AbstractSauceTunnelManager

/** Represents the operating system-specific Sauce Connect binary. */
public enum OperatingSystem {
OSX("darwin.all", "zip", null, UNIX_TEMP_DIR),
WINDOWS("windows.x86_64", "zip", null, WINDOWS_TEMP_DIR, "sc.exe"),
LINUX("linux.x86_64", "tar", "gz", UNIX_TEMP_DIR),
LINUX_ARM64("linux.aarch64", "tar", "gz", UNIX_TEMP_DIR);
OSX("darwin.all", "zip", null, UNIX_TEMP_DIR, "darwin"),
WINDOWS_AMD64("windows.x86_64", "zip", null, WINDOWS_TEMP_DIR, "windows-amd64", "sauce-connect.exe"),
WINDOWS_ARM64("windows.aarch64", "zip", null, WINDOWS_TEMP_DIR, "windows-arm64", "sauce-connect.exe"),
LINUX_AMD64("linux.x86_64", "tar", "gz", UNIX_TEMP_DIR, "linux-amd64"),
LINUX_ARM64("linux.aarch64", "tar", "gz", UNIX_TEMP_DIR, "linux-arm64");

private final String directoryEnding;
private final String archiveExtension;
private final String archiveFormat;
private final String compressionAlgorithm;
private final String executable;
private final String tempDirectory;
private final String downloadPlatform;

OperatingSystem(
String directoryEnding, String archiveFormat, String compressionAlgorithm, String tempDirectory,
String executable) {
String downloadPlatform, String executable) {
this.directoryEnding = directoryEnding;
this.archiveExtension = compressionAlgorithm == null ? archiveFormat : archiveFormat + "." + compressionAlgorithm;
this.archiveFormat = archiveFormat;
this.compressionAlgorithm = compressionAlgorithm;
this.executable = executable;
this.tempDirectory = tempDirectory;
this.downloadPlatform = downloadPlatform;
}

OperatingSystem(String directoryEnding, String archiveFormat, String compressionAlgorithm,
String tempDirectory) {
this(directoryEnding, archiveFormat, compressionAlgorithm, tempDirectory, "sc");
String tempDirectory, String downloadPlatform) {
this(directoryEnding, archiveFormat, compressionAlgorithm, tempDirectory, downloadPlatform, "sc");
}

public static OperatingSystem getOperatingSystem() {
String os = System.getProperty("os.name").toLowerCase();
if (isWindows(os)) {
return WINDOWS;
String arch = System.getProperty("os.arch").toLowerCase();

if (isArm(arch)) {
return WINDOWS_ARM64;
}
return WINDOWS_AMD64;
}
if (isMac(os)) {
return OSX;
Expand All @@ -89,7 +97,7 @@ public static OperatingSystem getOperatingSystem() {
if (isArm(arch)) {
return LINUX_ARM64;
}
return LINUX;
return LINUX_AMD64;
}
throw new IllegalStateException("Unsupported OS: " + os);
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,15 @@ public Void answer(InvocationOnMock invocation) throws Throwable {

@ParameterizedTest
@CsvSource({
"true, LINUX",
"true, WINDOWS",
"true, LINUX_AMD64",
"true, LINUX_ARM64",
"true, WINDOWS_AMD64",
"true, WINDOWS_ARM64",
"true, OSX",
"false, LINUX",
"false, WINDOWS",
"false, LINUX_AMD64",
"false, LINUX_ARM64",
"false, WINDOWS_AMD64",
"false, WINDOWS_ARM64",
"false, OSX"
})
void testExtractZipFile(boolean cleanUpOnExit, OperatingSystem operatingSystem,
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/saucelabs/sod/ExtractFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ class ExtractFiles {
static Stream<Arguments> operatingSystems() {
return Stream.of(
arguments(OperatingSystem.OSX, "sc"),
arguments(OperatingSystem.LINUX, "sc"),
arguments(OperatingSystem.LINUX_AMD64, "sc"),
arguments(OperatingSystem.LINUX_ARM64, "sc"),
arguments(OperatingSystem.WINDOWS, "sc.exe")
arguments(OperatingSystem.WINDOWS_AMD64, "sauce-connect.exe"),
arguments(OperatingSystem.WINDOWS_ARM64, "sauce-connect.exe")
);
}

Expand Down

0 comments on commit fe7ca48

Please sign in to comment.