Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #839: wrong binary on AIX downloaded #954

Merged
merged 1 commit into from Jan 29, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,7 +2,7 @@

import java.io.File;

enum Architecture { x86, x64, ppc64le, s390x, arm64, armv7l;
enum Architecture { x86, x64, ppc64le, s390x, arm64, armv7l, ppc, ppc64;
public static Architecture guess(){
String arch = System.getProperty("os.arch");
String version = System.getProperty("os.version");
Expand All @@ -15,19 +15,24 @@ public static Architecture guess(){
return s390x;
} else if (arch.equals("arm") && version.contains("v7")) {
return armv7l;
} else if (arch.equals("ppc64")) {
return ppc64;
} else if (arch.equals("ppc")) {
return ppc;
} else {
return arch.contains("64") ? x64 : x86;
}
}
}

enum OS { Windows, Mac, Linux, SunOS;
enum OS { Windows, Mac, Linux, SunOS, AIX;

public static OS guess() {
final String osName = System.getProperty("os.name");
return osName.contains("Windows") ? OS.Windows :
osName.contains("Mac") ? OS.Mac :
osName.contains("SunOS") ? OS.SunOS :
osName.contains("Aix") ? OS.AIX :
OS.Linux;
}

Expand All @@ -46,6 +51,8 @@ public String getCodename(){
return "win";
} else if(this == OS.SunOS){
return "sunos";
} else if(this == OS.AIX){
return "aix";
} else {
return "linux";
}
Expand Down
Expand Up @@ -81,4 +81,16 @@ public void detect_linux_alpine() throws Exception {
assertEquals("https://unofficial-builds.nodejs.org/download/release/",
platform.getNodeDownloadRoot());
}

@Test
public void detect_aix_ppc64() {
mockStatic(OS.class);
mockStatic(Architecture.class);

when(OS.guess()).thenReturn(OS.AIX);
when(Architecture.guess()).thenReturn(Architecture.ppc64);

Platform platform = Platform.guess();
assertEquals("aix-ppc64", platform.getNodeClassifier());
}
}