mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2026-04-29 03:25:55 -04:00
Use single means of determining platform and removes FreeBSD test support.
This commit is contained in:
committed by
Marco Vermeulen
parent
1ea407c8e5
commit
444e84a952
@@ -86,7 +86,7 @@ function __sdkman_determine_version() {
|
||||
echo ""
|
||||
__sdkman_echo_red "Stop! $candidate $version is not available. Possible causes:"
|
||||
__sdkman_echo_red " * $version is an invalid version"
|
||||
__sdkman_echo_red " * $candidate binaries are incompatible with $SDKMAN_PLATFORM"
|
||||
__sdkman_echo_red " * $candidate binaries are incompatible with your platform"
|
||||
__sdkman_echo_red " * $candidate has not been released yet"
|
||||
echo ""
|
||||
__sdkman_echo_yellow "Tip: see all available versions for your platform:"
|
||||
|
||||
@@ -87,7 +87,7 @@ function infer_platform() {
|
||||
esac
|
||||
}
|
||||
|
||||
SDKMAN_PLATFORM="$(infer_platform)"
|
||||
SDKMAN_PLATFORM="$(infer_platform | tr '[:upper:]' '[:lower:]')"
|
||||
export SDKMAN_PLATFORM
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
|
||||
@@ -20,17 +20,17 @@ class PlatformSpec extends SdkmanEnvSpecification {
|
||||
|
||||
where:
|
||||
kernel | machine | platform
|
||||
"Linux" | "i686" | "LinuxX32"
|
||||
"Linux" | "x86_64" | "LinuxX64"
|
||||
"Linux" | "armv7l" | "LinuxARM32"
|
||||
"Linux" | "armv8l" | "LinuxARM64"
|
||||
"Linux" | "aarch64" | "LinuxARM64"
|
||||
"Linux" | "" | "LinuxX64"
|
||||
"Darwin" | "x86_64" | "DarwinX64"
|
||||
"Darwin" | "arm64" | "DarwinARM64"
|
||||
"Darwin" | "" | "DarwinX64"
|
||||
"MSYS64" | "i686" | "MSYS64"
|
||||
"MSYS64" | "" | "MSYS64"
|
||||
"Linux" | "i686" | "linuxx32"
|
||||
"Linux" | "x86_64" | "linuxx64"
|
||||
"Linux" | "armv7l" | "linuxarm32"
|
||||
"Linux" | "armv8l" | "linuxarm64"
|
||||
"Linux" | "aarch64" | "linuxarm64"
|
||||
"Linux" | "" | "linuxx64"
|
||||
"Darwin" | "x86_64" | "darwinx64"
|
||||
"Darwin" | "arm64" | "darwinarm64"
|
||||
"Darwin" | "" | "darwinx64"
|
||||
"MSYS64" | "i686" | "msys64"
|
||||
"MSYS64" | "" | "msys64"
|
||||
}
|
||||
|
||||
def "should enable rosetta 2 compatibility mode with environment variable"() {
|
||||
@@ -47,7 +47,7 @@ class PlatformSpec extends SdkmanEnvSpecification {
|
||||
bash.execute('echo $SDKMAN_PLATFORM')
|
||||
|
||||
then:
|
||||
!bash.output.contains("DarwinARM64")
|
||||
bash.output.contains("DarwinX64")
|
||||
!bash.output.contains("darwinarm64")
|
||||
bash.output.contains("darwinx64")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,12 @@ package sdkman.steps
|
||||
|
||||
import com.github.tomakehurst.wiremock.client.WireMock
|
||||
import sdkman.support.FilesystemUtils
|
||||
import sdkman.support.UnixUtils
|
||||
import sdkman.support.WireMockServerProvider
|
||||
|
||||
import static cucumber.api.groovy.Hooks.After
|
||||
import static cucumber.api.groovy.Hooks.Before
|
||||
|
||||
HTTP_PROXY = System.getProperty("httpProxy") ?: ""
|
||||
PLATFORM = UnixUtils.platform.toLowerCase()
|
||||
|
||||
FAKE_JDK_PATH = "/path/to/my/openjdk"
|
||||
SERVICE_UP_HOST = "localhost"
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.zip.ZipFile
|
||||
import static cucumber.api.groovy.EN.And
|
||||
import static sdkman.stubs.WebServiceStub.primeEndpointWithString
|
||||
import static sdkman.stubs.WebServiceStub.primeSelfupdate
|
||||
import static sdkman.support.UnixUtils.asSdkmanPlatform
|
||||
|
||||
def BROADCAST_MESSAGE = "broadcast message"
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import static sdkman.support.FilesystemUtils.readVersionsCsvFromCandidateFolder
|
||||
|
||||
And(~'^the default "([^"]*)" version is "([^"]*)"$') { String candidate, String version ->
|
||||
primeEndpointWithString("/candidates/default/${candidate}", version)
|
||||
primeDownloadFor(SERVICE_UP_URL, candidate, version, PLATFORM)
|
||||
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${PLATFORM}", preInstallationHookSuccess())
|
||||
primeEndpointWithString("/hooks/post/${candidate}/${version}/${PLATFORM}", postInstallationHookSuccess())
|
||||
primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.asSdkmanPlatform())
|
||||
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", preInstallationHookSuccess())
|
||||
primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", postInstallationHookSuccess())
|
||||
}
|
||||
|
||||
And(~'^an available selfupdate$') { ->
|
||||
@@ -21,67 +21,67 @@ And(~'^an available selfupdate$') { ->
|
||||
}
|
||||
|
||||
And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') { String candidate, String version ->
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${PLATFORM}", "valid")
|
||||
primeDownloadFor(SERVICE_UP_URL, candidate, version, PLATFORM)
|
||||
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${PLATFORM}", preInstallationHookSuccess())
|
||||
primeEndpointWithString("/hooks/post/${candidate}/${version}/${PLATFORM}", postInstallationHookSuccess())
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", "valid")
|
||||
primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.asSdkmanPlatform())
|
||||
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", preInstallationHookSuccess())
|
||||
primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", postInstallationHookSuccess())
|
||||
}
|
||||
|
||||
And(~/^the appropriate universal hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String platform ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform)
|
||||
primeUniversalHookFor("pre", candidate, version, lcPlatform)
|
||||
primeUniversalHookFor("post", candidate, version, lcPlatform)
|
||||
}
|
||||
|
||||
And(~/^the appropriate multi-platform hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)" with architecture "(.*)"$/) { String candidate, String version, String platform, String architecture ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture)
|
||||
primePlatformSpecificHookFor("pre", candidate, version, lcPlatform)
|
||||
primePlatformSpecificHookFor("post", candidate, version, lcPlatform)
|
||||
}
|
||||
|
||||
And(~'^the candidate "([^"]*)" version "([^"]*)" is not available for download$') { String candidate, String version ->
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${PLATFORM}", "invalid")
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", "invalid")
|
||||
}
|
||||
|
||||
And(~/^the candidate "(.*)" version "(.*)" is available for download on "(.*)" with architecture "(.*)"$/) { String candidate, String version, String platform, String architecture ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture)
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${lcPlatform}", "valid")
|
||||
primeDownloadFor(SERVICE_UP_URL, candidate, version, lcPlatform)
|
||||
}
|
||||
|
||||
And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns successfully$/) { String phase, String candidate, String version, String platform, String architecture ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture)
|
||||
primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookSuccess() : postInstallationHookSuccess())
|
||||
}
|
||||
|
||||
And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns a failure$/) { String phase, String candidate, String version, String platform, String architecture ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture)
|
||||
primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookFailure() : postInstallationHookFailure())
|
||||
}
|
||||
|
||||
And(~/^the candidate "(.*?)" version "(.*?)" is not available for download on "(.*?)"$/) { String candidate, String version, String platform ->
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
|
||||
String lcPlatform = UnixUtils.asSdkmanPlatform(platform)
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${lcPlatform}", "invalid")
|
||||
}
|
||||
|
||||
And(~'^a "([^"]*)" list view is available for consumption$') { String candidate ->
|
||||
primeEndpointWithString("/candidates/${candidate}/${UnixUtils.platform}/versions/list?current=&installed=", "Available ${candidate.capitalize()} Versions")
|
||||
primeEndpointWithString("/candidates/${candidate}/${UnixUtils.asSdkmanPlatform()}/versions/list?current=&installed=", "Available ${candidate.capitalize()} Versions")
|
||||
}
|
||||
|
||||
And(~'^the candidate "([^"]*)" version "([^"]*)" is a valid candidate version$') { String candidate, String version ->
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${PLATFORM}", "valid")
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", "valid")
|
||||
}
|
||||
|
||||
And(~'^the candidate "([^"]*)" version "([^"]*)" is not a valid candidate version$') { String candidate, String version ->
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${PLATFORM}", "invalid")
|
||||
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", "invalid")
|
||||
}
|
||||
|
||||
And(~/^the candidate "(.*?)" has a version list available$/) { String candidate ->
|
||||
def current = readCurrentFromCandidateFolder(candidatesDir, candidate)
|
||||
def versions = readVersionsCsvFromCandidateFolder(candidatesDir, candidate)
|
||||
def url = "/candidates/${candidate}/${UnixUtils.platform}/versions/list?current=${current}&installed=${versions}"
|
||||
def url = "/candidates/${candidate}/${UnixUtils.asSdkmanPlatform()}/versions/list?current=${current}&installed=${versions}"
|
||||
println("Priming url: $url")
|
||||
primeEndpointWithString(url, "Candidate: $candidate; Versions: $versions; Current: $current; Platform: ${UnixUtils.platform}")
|
||||
primeEndpointWithString(url, "Candidate: $candidate; Versions: $versions; Current: $current; Platform: ${UnixUtils.asSdkmanPlatform()}")
|
||||
}
|
||||
|
||||
And(~/^The candidate list is available$/) { ->
|
||||
|
||||
@@ -3,7 +3,6 @@ package sdkman.stubs
|
||||
class UnameStub {
|
||||
|
||||
private File file
|
||||
private platform = "Linux"
|
||||
private kernel = "Linux"
|
||||
private machine = "X86_64"
|
||||
|
||||
@@ -28,11 +27,6 @@ class UnameStub {
|
||||
this
|
||||
}
|
||||
|
||||
UnameStub forPlatform(String uname) {
|
||||
this.platform = uname
|
||||
this
|
||||
}
|
||||
|
||||
void build() {
|
||||
file << """
|
||||
|if [[ "\$1" == '-m' ]]; then
|
||||
@@ -40,7 +34,7 @@ class UnameStub {
|
||||
|elif [[ "\$1" == '-s' ]]; then
|
||||
| echo "$kernel"
|
||||
|else
|
||||
| echo "$platform"
|
||||
| echo "$machine"
|
||||
|fi
|
||||
""".stripMargin('|')
|
||||
}
|
||||
|
||||
@@ -8,21 +8,12 @@ class UnixUtils {
|
||||
],
|
||||
"Mac OS X": [
|
||||
"x86_64": "DarwinX64",
|
||||
],
|
||||
"FreeBSD": [
|
||||
"amd64": "FreeBSD_X64"
|
||||
]
|
||||
]
|
||||
|
||||
static getPlatform() {
|
||||
def sdkmanPlatform = asSdkmanPlatform(System.getProperty("os.name"), System.getProperty("os.arch"))
|
||||
println("Setting platform for test: $sdkmanPlatform")
|
||||
sdkmanPlatform
|
||||
}
|
||||
|
||||
static asSdkmanPlatform(
|
||||
platform = System.getProperty("os.name"),
|
||||
architecture = System.getProperty("os.arch")) {
|
||||
platforms[platform][architecture] ?: platform
|
||||
(platforms[platform][architecture] ?: platform).toLowerCase()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,27 +41,27 @@ Feature: Java Multi Platform Binary Distribution
|
||||
And I see "Cannot install java 8.0.101 at this time..."
|
||||
|
||||
Scenario: Platform is not supported for specific version and user is notified
|
||||
And an "amd64" machine with "FreeBSD" installed
|
||||
And an "amd64" machine with "Linux" installed
|
||||
And the system is bootstrapped
|
||||
And the candidate "java" version "8.0.111" is not available for download on "FreeBSD"
|
||||
And the candidate "java" version "8.0.111" is not available for download on "Linux"
|
||||
When I enter "sdk install java 8.0.111"
|
||||
Then I see "Stop! java 8.0.111 is not available. Possible causes:"
|
||||
And I see " * 8.0.111 is an invalid version"
|
||||
And I see " * java binaries are incompatible with FreeBSD"
|
||||
And I see " * java binaries are incompatible with your platform"
|
||||
And I see " * java has not been released yet"
|
||||
And I see "Tip: see all available versions for your platform:"
|
||||
And I see "$ sdk list java"
|
||||
And the candidate "java" version "8.0.111" is not installed
|
||||
|
||||
Scenario: Platform is not supported for default version and user is notified
|
||||
And an "amd64" machine with "FreeBSD" installed
|
||||
And an "amd64" machine with "Linux" installed
|
||||
And the system is bootstrapped
|
||||
And the default "java" version is "8.0.111"
|
||||
And the candidate "java" version "8.0.111" is not available for download on "FreeBSD"
|
||||
And the candidate "java" version "8.0.111" is not available for download on "Linux"
|
||||
When I enter "sdk install java"
|
||||
Then I see "Stop! java 8.0.111 is not available. Possible causes:"
|
||||
And I see " * 8.0.111 is an invalid version"
|
||||
And I see " * java binaries are incompatible with FreeBSD"
|
||||
And I see " * java binaries are incompatible with your platform"
|
||||
And I see " * java has not been released yet"
|
||||
And I see "Tip: see all available versions for your platform:"
|
||||
And I see "$ sdk list java"
|
||||
|
||||
Reference in New Issue
Block a user