Skip to content

Commit 444e84a

Browse files
committed
Use single means of determining platform and removes FreeBSD test support.
1 parent 1ea407c commit 444e84a

File tree

9 files changed

+42
-60
lines changed

9 files changed

+42
-60
lines changed

src/main/bash/sdkman-env-helpers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function __sdkman_determine_version() {
8686
echo ""
8787
__sdkman_echo_red "Stop! $candidate $version is not available. Possible causes:"
8888
__sdkman_echo_red " * $version is an invalid version"
89-
__sdkman_echo_red " * $candidate binaries are incompatible with $SDKMAN_PLATFORM"
89+
__sdkman_echo_red " * $candidate binaries are incompatible with your platform"
9090
__sdkman_echo_red " * $candidate has not been released yet"
9191
echo ""
9292
__sdkman_echo_yellow "Tip: see all available versions for your platform:"

src/main/bash/sdkman-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function infer_platform() {
8787
esac
8888
}
8989

90-
SDKMAN_PLATFORM="$(infer_platform)"
90+
SDKMAN_PLATFORM="$(infer_platform | tr '[:upper:]' '[:lower:]')"
9191
export SDKMAN_PLATFORM
9292

9393
# OS specific support (must be 'true' or 'false').

src/test/groovy/sdkman/specs/PlatformSpec.groovy

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ class PlatformSpec extends SdkmanEnvSpecification {
2020

2121
where:
2222
kernel | machine | platform
23-
"Linux" | "i686" | "LinuxX32"
24-
"Linux" | "x86_64" | "LinuxX64"
25-
"Linux" | "armv7l" | "LinuxARM32"
26-
"Linux" | "armv8l" | "LinuxARM64"
27-
"Linux" | "aarch64" | "LinuxARM64"
28-
"Linux" | "" | "LinuxX64"
29-
"Darwin" | "x86_64" | "DarwinX64"
30-
"Darwin" | "arm64" | "DarwinARM64"
31-
"Darwin" | "" | "DarwinX64"
32-
"MSYS64" | "i686" | "MSYS64"
33-
"MSYS64" | "" | "MSYS64"
23+
"Linux" | "i686" | "linuxx32"
24+
"Linux" | "x86_64" | "linuxx64"
25+
"Linux" | "armv7l" | "linuxarm32"
26+
"Linux" | "armv8l" | "linuxarm64"
27+
"Linux" | "aarch64" | "linuxarm64"
28+
"Linux" | "" | "linuxx64"
29+
"Darwin" | "x86_64" | "darwinx64"
30+
"Darwin" | "arm64" | "darwinarm64"
31+
"Darwin" | "" | "darwinx64"
32+
"MSYS64" | "i686" | "msys64"
33+
"MSYS64" | "" | "msys64"
3434
}
3535

3636
def "should enable rosetta 2 compatibility mode with environment variable"() {
@@ -47,7 +47,7 @@ class PlatformSpec extends SdkmanEnvSpecification {
4747
bash.execute('echo $SDKMAN_PLATFORM')
4848

4949
then:
50-
!bash.output.contains("DarwinARM64")
51-
bash.output.contains("DarwinX64")
50+
!bash.output.contains("darwinarm64")
51+
bash.output.contains("darwinx64")
5252
}
5353
}

src/test/groovy/sdkman/steps/env.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ package sdkman.steps
22

33
import com.github.tomakehurst.wiremock.client.WireMock
44
import sdkman.support.FilesystemUtils
5-
import sdkman.support.UnixUtils
65
import sdkman.support.WireMockServerProvider
76

87
import static cucumber.api.groovy.Hooks.After
98
import static cucumber.api.groovy.Hooks.Before
109

1110
HTTP_PROXY = System.getProperty("httpProxy") ?: ""
12-
PLATFORM = UnixUtils.platform.toLowerCase()
1311

1412
FAKE_JDK_PATH = "/path/to/my/openjdk"
1513
SERVICE_UP_HOST = "localhost"

src/test/groovy/sdkman/steps/initialisation_steps.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import java.util.zip.ZipFile
99
import static cucumber.api.groovy.EN.And
1010
import static sdkman.stubs.WebServiceStub.primeEndpointWithString
1111
import static sdkman.stubs.WebServiceStub.primeSelfupdate
12-
import static sdkman.support.UnixUtils.asSdkmanPlatform
1312

1413
def BROADCAST_MESSAGE = "broadcast message"
1514

src/test/groovy/sdkman/steps/stub_steps.groovy

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,77 +11,77 @@ import static sdkman.support.FilesystemUtils.readVersionsCsvFromCandidateFolder
1111

1212
And(~'^the default "([^"]*)" version is "([^"]*)"$') { String candidate, String version ->
1313
primeEndpointWithString("/candidates/default/${candidate}", version)
14-
primeDownloadFor(SERVICE_UP_URL, candidate, version, PLATFORM)
15-
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${PLATFORM}", preInstallationHookSuccess())
16-
primeEndpointWithString("/hooks/post/${candidate}/${version}/${PLATFORM}", postInstallationHookSuccess())
14+
primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.asSdkmanPlatform())
15+
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", preInstallationHookSuccess())
16+
primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", postInstallationHookSuccess())
1717
}
1818

1919
And(~'^an available selfupdate$') { ->
2020
primeEndpointWithString("/selfupdate?beta=false", 'echo "Successfully upgraded SDKMAN."')
2121
}
2222

2323
And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') { String candidate, String version ->
24-
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${PLATFORM}", "valid")
25-
primeDownloadFor(SERVICE_UP_URL, candidate, version, PLATFORM)
26-
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${PLATFORM}", preInstallationHookSuccess())
27-
primeEndpointWithString("/hooks/post/${candidate}/${version}/${PLATFORM}", postInstallationHookSuccess())
24+
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", "valid")
25+
primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.asSdkmanPlatform())
26+
primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", preInstallationHookSuccess())
27+
primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", postInstallationHookSuccess())
2828
}
2929

3030
And(~/^the appropriate universal hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String platform ->
31-
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
31+
String lcPlatform = UnixUtils.asSdkmanPlatform(platform)
3232
primeUniversalHookFor("pre", candidate, version, lcPlatform)
3333
primeUniversalHookFor("post", candidate, version, lcPlatform)
3434
}
3535

3636
And(~/^the appropriate multi-platform hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)" with architecture "(.*)"$/) { String candidate, String version, String platform, String architecture ->
37-
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture).toLowerCase()
37+
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture)
3838
primePlatformSpecificHookFor("pre", candidate, version, lcPlatform)
3939
primePlatformSpecificHookFor("post", candidate, version, lcPlatform)
4040
}
4141

4242
And(~'^the candidate "([^"]*)" version "([^"]*)" is not available for download$') { String candidate, String version ->
43-
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${PLATFORM}", "invalid")
43+
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", "invalid")
4444
}
4545

4646
And(~/^the candidate "(.*)" version "(.*)" is available for download on "(.*)" with architecture "(.*)"$/) { String candidate, String version, String platform, String architecture ->
47-
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture).toLowerCase()
47+
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture)
4848
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${lcPlatform}", "valid")
4949
primeDownloadFor(SERVICE_UP_URL, candidate, version, lcPlatform)
5050
}
5151

5252
And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns successfully$/) { String phase, String candidate, String version, String platform, String architecture ->
53-
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture).toLowerCase()
53+
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture)
5454
primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookSuccess() : postInstallationHookSuccess())
5555
}
5656

5757
And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns a failure$/) { String phase, String candidate, String version, String platform, String architecture ->
58-
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture).toLowerCase()
58+
String lcPlatform = UnixUtils.asSdkmanPlatform(platform, architecture)
5959
primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookFailure() : postInstallationHookFailure())
6060
}
6161

6262
And(~/^the candidate "(.*?)" version "(.*?)" is not available for download on "(.*?)"$/) { String candidate, String version, String platform ->
63-
String lcPlatform = UnixUtils.asSdkmanPlatform(platform).toLowerCase()
63+
String lcPlatform = UnixUtils.asSdkmanPlatform(platform)
6464
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${lcPlatform}", "invalid")
6565
}
6666

6767
And(~'^a "([^"]*)" list view is available for consumption$') { String candidate ->
68-
primeEndpointWithString("/candidates/${candidate}/${UnixUtils.platform}/versions/list?current=&installed=", "Available ${candidate.capitalize()} Versions")
68+
primeEndpointWithString("/candidates/${candidate}/${UnixUtils.asSdkmanPlatform()}/versions/list?current=&installed=", "Available ${candidate.capitalize()} Versions")
6969
}
7070

7171
And(~'^the candidate "([^"]*)" version "([^"]*)" is a valid candidate version$') { String candidate, String version ->
72-
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${PLATFORM}", "valid")
72+
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", "valid")
7373
}
7474

7575
And(~'^the candidate "([^"]*)" version "([^"]*)" is not a valid candidate version$') { String candidate, String version ->
76-
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${PLATFORM}", "invalid")
76+
primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.asSdkmanPlatform()}", "invalid")
7777
}
7878

7979
And(~/^the candidate "(.*?)" has a version list available$/) { String candidate ->
8080
def current = readCurrentFromCandidateFolder(candidatesDir, candidate)
8181
def versions = readVersionsCsvFromCandidateFolder(candidatesDir, candidate)
82-
def url = "/candidates/${candidate}/${UnixUtils.platform}/versions/list?current=${current}&installed=${versions}"
82+
def url = "/candidates/${candidate}/${UnixUtils.asSdkmanPlatform()}/versions/list?current=${current}&installed=${versions}"
8383
println("Priming url: $url")
84-
primeEndpointWithString(url, "Candidate: $candidate; Versions: $versions; Current: $current; Platform: ${UnixUtils.platform}")
84+
primeEndpointWithString(url, "Candidate: $candidate; Versions: $versions; Current: $current; Platform: ${UnixUtils.asSdkmanPlatform()}")
8585
}
8686

8787
And(~/^The candidate list is available$/) { ->

src/test/groovy/sdkman/stubs/UnameStub.groovy

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package sdkman.stubs
33
class UnameStub {
44

55
private File file
6-
private platform = "Linux"
76
private kernel = "Linux"
87
private machine = "X86_64"
98

@@ -28,19 +27,14 @@ class UnameStub {
2827
this
2928
}
3029

31-
UnameStub forPlatform(String uname) {
32-
this.platform = uname
33-
this
34-
}
35-
3630
void build() {
3731
file << """
3832
|if [[ "\$1" == '-m' ]]; then
3933
| echo "$machine"
4034
|elif [[ "\$1" == '-s' ]]; then
4135
| echo "$kernel"
4236
|else
43-
| echo "$platform"
37+
| echo "$machine"
4438
|fi
4539
""".stripMargin('|')
4640
}

src/test/groovy/sdkman/support/UnixUtils.groovy

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,12 @@ class UnixUtils {
88
],
99
"Mac OS X": [
1010
"x86_64": "DarwinX64",
11-
],
12-
"FreeBSD": [
13-
"amd64": "FreeBSD_X64"
1411
]
1512
]
16-
17-
static getPlatform() {
18-
def sdkmanPlatform = asSdkmanPlatform(System.getProperty("os.name"), System.getProperty("os.arch"))
19-
println("Setting platform for test: $sdkmanPlatform")
20-
sdkmanPlatform
21-
}
2213

2314
static asSdkmanPlatform(
2415
platform = System.getProperty("os.name"),
2516
architecture = System.getProperty("os.arch")) {
26-
platforms[platform][architecture] ?: platform
17+
(platforms[platform][architecture] ?: platform).toLowerCase()
2718
}
2819
}

src/test/resources/features/java_installation.feature

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ Feature: Java Multi Platform Binary Distribution
4141
And I see "Cannot install java 8.0.101 at this time..."
4242

4343
Scenario: Platform is not supported for specific version and user is notified
44-
And an "amd64" machine with "FreeBSD" installed
44+
And an "amd64" machine with "Linux" installed
4545
And the system is bootstrapped
46-
And the candidate "java" version "8.0.111" is not available for download on "FreeBSD"
46+
And the candidate "java" version "8.0.111" is not available for download on "Linux"
4747
When I enter "sdk install java 8.0.111"
4848
Then I see "Stop! java 8.0.111 is not available. Possible causes:"
4949
And I see " * 8.0.111 is an invalid version"
50-
And I see " * java binaries are incompatible with FreeBSD"
50+
And I see " * java binaries are incompatible with your platform"
5151
And I see " * java has not been released yet"
5252
And I see "Tip: see all available versions for your platform:"
5353
And I see "$ sdk list java"
5454
And the candidate "java" version "8.0.111" is not installed
5555

5656
Scenario: Platform is not supported for default version and user is notified
57-
And an "amd64" machine with "FreeBSD" installed
57+
And an "amd64" machine with "Linux" installed
5858
And the system is bootstrapped
5959
And the default "java" version is "8.0.111"
60-
And the candidate "java" version "8.0.111" is not available for download on "FreeBSD"
60+
And the candidate "java" version "8.0.111" is not available for download on "Linux"
6161
When I enter "sdk install java"
6262
Then I see "Stop! java 8.0.111 is not available. Possible causes:"
6363
And I see " * 8.0.111 is an invalid version"
64-
And I see " * java binaries are incompatible with FreeBSD"
64+
And I see " * java binaries are incompatible with your platform"
6565
And I see " * java has not been released yet"
6666
And I see "Tip: see all available versions for your platform:"
6767
And I see "$ sdk list java"

0 commit comments

Comments
 (0)