mirror of
https://github.com/sdkman/sdkman-cli.git
synced 2025-12-23 22:58:22 -05:00
Fix broken platform tests and remove obsolete PlatformSpec.
This commit is contained in:
@@ -3,6 +3,7 @@ package sdkman.env
|
||||
import groovy.transform.ToString
|
||||
import sdkman.stubs.CurlStub
|
||||
import sdkman.stubs.UnameStub
|
||||
import sdkman.support.UnixUtils
|
||||
|
||||
@ToString(includeNames = true)
|
||||
class SdkmanBashEnvBuilder {
|
||||
@@ -19,6 +20,7 @@ class SdkmanBashEnvBuilder {
|
||||
private Optional<CurlStub> curlStub = Optional.empty()
|
||||
private Optional<UnameStub> unameStub = Optional.empty()
|
||||
private List candidates = ['groovy', 'grails', 'java']
|
||||
private String platform = UnixUtils.inferPlatform()
|
||||
private boolean offlineMode = false
|
||||
private String candidatesApi = "http://localhost:8080/2"
|
||||
private String jdkHome = "/path/to/my/jdk"
|
||||
@@ -53,6 +55,11 @@ class SdkmanBashEnvBuilder {
|
||||
this.unameStub = Optional.of(unameStub)
|
||||
this
|
||||
}
|
||||
|
||||
SdkmanBashEnvBuilder withPlatform(String platform) {
|
||||
this.platform = platform
|
||||
this
|
||||
}
|
||||
|
||||
SdkmanBashEnvBuilder withCandidates(List candidates) {
|
||||
this.candidates = candidates
|
||||
@@ -116,6 +123,7 @@ class SdkmanBashEnvBuilder {
|
||||
|
||||
initializeCandidates(sdkmanCandidatesDir, candidates)
|
||||
initializeCandidatesCache(sdkmanVarDir, candidates)
|
||||
initializePlatformDescriptor(sdkmanEtcDir, platform)
|
||||
initializeConfiguration(sdkmanEtcDir, config)
|
||||
initializeScriptVersionFile(sdkmanVarDir, scriptVersion)
|
||||
initializeNativeVersionFile(sdkmanVarDir, nativeVersion)
|
||||
@@ -172,6 +180,11 @@ class SdkmanBashEnvBuilder {
|
||||
candidatesCache << ""
|
||||
}
|
||||
}
|
||||
|
||||
private initializePlatformDescriptor(File folder, String platform) {
|
||||
def platformDescriptor = new File(folder, "platform")
|
||||
platformDescriptor << platform
|
||||
}
|
||||
|
||||
private initializeConfiguration(File targetFolder, Map config) {
|
||||
def configFile = new File(targetFolder, "config")
|
||||
|
||||
@@ -49,6 +49,7 @@ class CompletionSpec extends SdkmanEnvSpecification {
|
||||
bash = sdkmanBashEnvBuilder
|
||||
.withConfiguration("sdkman_auto_complete", "true")
|
||||
.withUnameStub(unameStub)
|
||||
.withPlatform("darwinx64")
|
||||
.build()
|
||||
|
||||
bash.start()
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
package sdkman.specs
|
||||
|
||||
import sdkman.support.SdkmanEnvSpecification
|
||||
|
||||
class PlatformSpec extends SdkmanEnvSpecification {
|
||||
def setup() {
|
||||
sdkmanBashEnvBuilder.withCandidates(["groovy"])
|
||||
}
|
||||
|
||||
def "should set platform based on uname"() {
|
||||
given:
|
||||
unameStub.forKernel(kernel).forMachine(machine)
|
||||
bash = sdkmanBashEnvBuilder.withUnameStub(unameStub).build()
|
||||
bash.start()
|
||||
bash.execute("source $bootstrapScript")
|
||||
bash.execute('echo $SDKMAN_PLATFORM')
|
||||
|
||||
expect:
|
||||
bash.output.contains(platform)
|
||||
|
||||
where:
|
||||
kernel | machine | platform
|
||||
"Linux" | "i686" | "linuxx32"
|
||||
"Linux" | "x86_64" | "linuxx64"
|
||||
"Linux" | "armv6l" | "linuxarm32hf"
|
||||
"Linux" | "armv7l" | "linuxarm32hf"
|
||||
"Linux" | "armv8l" | "linuxarm32hf"
|
||||
"Linux" | "aarch64" | "linuxarm64"
|
||||
"Linux" | "alpha" | "exotic"
|
||||
"Linux" | "i64" | "exotic"
|
||||
"Linux" | "ppc" | "exotic"
|
||||
"Linux" | "ppc64le" | "exotic"
|
||||
"Linux" | "ppc64el" | "exotic"
|
||||
"Linux" | "s390" | "exotic"
|
||||
"Linux" | "s390x" | "exotic"
|
||||
"Linux" | "" | "exotic"
|
||||
"Darwin" | "x86_64" | "darwinx64"
|
||||
"Darwin" | "arm64" | "darwinarm64"
|
||||
"Darwin" | "" | "darwinx64"
|
||||
"MSYS64" | "i686" | "msys64"
|
||||
"MSYS64" | "" | "msys64"
|
||||
"CYGWIN" | "" | "exotic"
|
||||
}
|
||||
|
||||
def "should enable rosetta 2 compatibility mode with environment variable"() {
|
||||
given:
|
||||
unameStub.forKernel("Darwin").forMachine("arm64")
|
||||
bash = sdkmanBashEnvBuilder
|
||||
.withUnameStub(unameStub)
|
||||
.withConfiguration("sdkman_rosetta2_compatible", "true")
|
||||
.build()
|
||||
bash.start()
|
||||
bash.execute("source $bootstrapScript")
|
||||
|
||||
when:
|
||||
bash.execute('echo $SDKMAN_PLATFORM')
|
||||
|
||||
then:
|
||||
!bash.output.contains("darwinarm64")
|
||||
bash.output.contains("darwinx64")
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package sdkman.stubs
|
||||
class UnameStub {
|
||||
|
||||
private File file
|
||||
private kernel = "Linux"
|
||||
private machine = "X86_64"
|
||||
def kernel = "Linux"
|
||||
def machine = "x86_64"
|
||||
|
||||
static UnameStub prepareIn(File folder) {
|
||||
folder.mkdirs()
|
||||
|
||||
@@ -4,11 +4,13 @@ class UnixUtils {
|
||||
|
||||
private static platforms = [
|
||||
"Linux" : [
|
||||
"x86_64": "LinuxX64"
|
||||
"x86_64": "linuxx64",
|
||||
"aarch64": "linuxarm64",
|
||||
|
||||
],
|
||||
"Darwin": [
|
||||
"x86_64": "DarwinX64",
|
||||
"arm64": "DarwinX64",
|
||||
"x86_64": "darwinx64",
|
||||
"arm64": "darwinarm64",
|
||||
]
|
||||
]
|
||||
|
||||
@@ -23,6 +25,6 @@ class UnixUtils {
|
||||
static inferPlatform(
|
||||
String osName = osName(),
|
||||
String architecture = osArch()) {
|
||||
(platforms[osName][architecture] ?: osName).toLowerCase()
|
||||
platforms[osName][architecture] ?: osName.toLowerCase()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +81,7 @@ Feature: Mnemonics
|
||||
And the candidate "groovy" version "2.0.5" should be the default
|
||||
|
||||
Scenario: Shortcut for displaying Home directory
|
||||
Given an initialised environment without debug prints
|
||||
And the candidate "grails" version "2.1.0" is already installed and default
|
||||
Given the candidate "grails" version "2.1.0" is already installed and default
|
||||
And the candidate "grails" version "2.1.0" is a valid candidate version
|
||||
And the system is bootstrapped
|
||||
When I enter "sdk h grails 2.1.0"
|
||||
|
||||
Reference in New Issue
Block a user