Skip to content

Commit

Permalink
Merge pull request #954 from bmarwell/839-aix
Browse files Browse the repository at this point in the history
fix #839: wrong binary on AIX downloaded
  • Loading branch information
eirslett committed Jan 29, 2021
2 parents 3723ff7 + 0ec064d commit db8072a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
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());
}
}

0 comments on commit db8072a

Please sign in to comment.