Skip to content

Commit

Permalink
Fix broken platform tests and remove obsolete PlatformSpec.
Browse files Browse the repository at this point in the history
  • Loading branch information
marc0der committed May 14, 2023
1 parent 33a4adf commit a5f07d6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 70 deletions.
13 changes: 13 additions & 0 deletions src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -116,6 +123,7 @@ class SdkmanBashEnvBuilder {

initializeCandidates(sdkmanCandidatesDir, candidates)
initializeCandidatesCache(sdkmanVarDir, candidates)
initializePlatformDescriptor(sdkmanEtcDir, platform)
initializeConfiguration(sdkmanEtcDir, config)
initializeScriptVersionFile(sdkmanVarDir, scriptVersion)
initializeNativeVersionFile(sdkmanVarDir, nativeVersion)
Expand Down Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions src/test/groovy/sdkman/specs/CompletionSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class CompletionSpec extends SdkmanEnvSpecification {
bash = sdkmanBashEnvBuilder
.withConfiguration("sdkman_auto_complete", "true")
.withUnameStub(unameStub)
.withPlatform("darwinx64")
.build()

bash.start()
Expand Down
62 changes: 0 additions & 62 deletions src/test/groovy/sdkman/specs/PlatformSpec.groovy

This file was deleted.

4 changes: 2 additions & 2 deletions src/test/groovy/sdkman/stubs/UnameStub.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 6 additions & 4 deletions src/test/groovy/sdkman/support/UnixUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
]

Expand All @@ -23,6 +25,6 @@ class UnixUtils {
static inferPlatform(
String osName = osName(),
String architecture = osArch()) {
(platforms[osName][architecture] ?: osName).toLowerCase()
platforms[osName][architecture] ?: osName.toLowerCase()
}
}
3 changes: 1 addition & 2 deletions src/test/resources/features/mnemonics.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a5f07d6

Please sign in to comment.