diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e1500cac6..960ecf272 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -7,13 +7,13 @@ assignees: '' --- - + **Bug report** **To reproduce** - + **System info** + - [ ] I have read the [CONTRIBUTING guidelines](CONTRIBUTING.md) -- [ ] I've had a conversation on the [#cli-development](https://sdkman.slack.com/app_redirect?channel=cli-development) Slack channel about this request. +- [ ] I've had a conversation on our community [Discord](https://discord.gg/y9mVJYVyu4) server. **Feature request** - + diff --git a/.github/ISSUE_TEMPLATE/support_request.md b/.github/ISSUE_TEMPLATE/support_request.md index 495d79fb6..e3a2d9b11 100644 --- a/.github/ISSUE_TEMPLATE/support_request.md +++ b/.github/ISSUE_TEMPLATE/support_request.md @@ -6,13 +6,13 @@ labels: 'support' assignees: '' --- - +Please consider the following things. Just so you know, ignoring any of these might lead to the issue being closed abruptly. --> - [ ] I have checked [the documentation](https://sdkman.io/usage) -- [ ] I have done a quick search in [past issues](https://github.com/rclone/rclone/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems -- [ ] I have brought up a conversation in the [Slack User Issues Channel](https://sdkman.slack.com/app_redirect?channel=user-issues) +- [ ] I have performed a quick search in [past issues](https://github.com/sdkman/sdkman-cli/issues?q=) or [Stack Overflow](https://stackoverflow.com/questions/tagged/sdkman) for similar problems +- [ ] I have brought up a conversation in the community [Discord](https://discord.gg/y9mVJYVyu4) server **Question** diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..253bcb76b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily diff --git a/.github/pull_request_tempalte.md b/.github/pull_request_template.md similarity index 100% rename from .github/pull_request_tempalte.md rename to .github/pull_request_template.md diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 3bc91572e..f81b90c3c 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -3,6 +3,8 @@ on: push: branches: - master + paths-ignore: + - .github/workflows/* jobs: pre-release: @@ -15,11 +17,12 @@ jobs: ports: - 27017:27017 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '11' + cache: 'gradle' - name: Run tests run: ./gradlew clean test --info - name: Set short git hash diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b275393ab..cb6c96662 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,15 +5,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '11' + cache: 'gradle' - name: Run with Gradle run: ./gradlew clean test --info - - uses: kentaro-m/auto-assign-action@v1.1.2 + - uses: kentaro-m/auto-assign-action@v1.2.5 with: configuration-path: ".github/auto_assign.yml" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 285c92244..33b7ee1f6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,25 +17,27 @@ jobs: JRELEASER_TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_API_SECRET }} JRELEASER_TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }} JRELEASER_TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }} + JRELEASER_MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN}} services: mongodb: image: mongo:3.2 ports: - 27017:27017 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-java@v2 + - uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '11' + cache: 'gradle' - name: Run tests run: ./gradlew clean test --info - name: Build artifacts run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} clean assemble - name: Release - run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} jreleaserRelease + run: ./gradlew -Penv=stable -Prelease=${{ github.event.inputs.version }} jreleaserFullRelease --exclude-announcer=twitter - name: Update MongoDB env: MONGO_URL: ${{ secrets.MONGO_URL }} diff --git a/.sdkmanrc b/.sdkmanrc index 42efcf3ea..985fcd876 100644 --- a/.sdkmanrc +++ b/.sdkmanrc @@ -1,3 +1,3 @@ # Enable auto-env through the sdkman_auto_env config # Add key=value pairs of SDKs to use below -java=11.0.13-tem +java=11.0.17-tem diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4dadcf056..7cb30a3a1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,17 +2,14 @@ We greatly value the feedback and contributions of our users. -We keep a distinction between Bugs/Issues, New Features and Support Requests. We also try to minimise the noise in our GitHub Issues stream and prefer having a conversation on [SDKMAN Slack](https://slack.sdkman.io) before creating new issues, if you are not fully sure how to categorize your request. Simply sign up and join one of the following channels: +We distinguish between Bugs/Issues, New Features and Support Requests. We also try to minimise the noise in our GitHub Issues stream and prefer having a conversation on [SDKMAN Discord](https://discord.gg/y9mVJYVyu4) before creating new issues if you are not entirely sure how to categorize your request. Sign up and join our Help channel. -- User Issues can be raised in our [User Issues channel](https://sdkman.slack.com/app_redirect?channel=user-issues). -- New Features or Enhancements can be discussed in our [CLI Development channel](https://sdkman.slack.com/app_redirect?channel=cli-development). +The [GitHub Issue Tracker](https://github.com/sdkman/sdkman-cli/issues/new) provides templates for required information. -The [GitHub Issue Tracker](https://github.com/sdkman/sdkman-cli/issues/new) provides templates for required informations. - -**Unfortunately we might simply close any Github Issues that have not followed the requested template.** +**Unfortunately, we might close any GitHub Issues that have not followed the requested template.** ### Pull Requests -Pull Requests are _always_ very welcome, but require a valid GitHub Issue as decribed above. The PR template is to be filled in before submission, ensuring that it is _linked back_ to the Github Issue number by replacing `#XXX` with the appropriate issue reference. +Pull Requests are _always_ very welcome but require a valid GitHub Issue as described above. The PR template is to be filled in before submission, ensuring that it is _linked back_ to the GitHub Issue number by replacing `#XXX` with the appropriate issue reference. -Each PR should also be accompanied by a passing test(s) proving it's validity (where feasible). The feasibility of the test will emerge in the initial discussions of the issue. +Each PR should also be accompanied by a passing test(s) proving its validity (where feasible). The feasibility of the test will emerge in the initial discussions of the issue. diff --git a/README.md b/README.md index 3768ae94d..9442867fe 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,20 @@ # SDKMAN! CLI ### The Software Development Kit Manager Command Line Interface -[![Backers on Open Collective](https://opencollective.com/sdkman/backers/badge.svg)](#backers) -[![Sponsors on Open Collective](https://opencollective.com/sdkman/sponsors/badge.svg)](#sponsors) -[![Slack](https://slack.sdkman.io/badge.svg)](https://slack.sdkman.io) +[![Backers on Open Collective](https://img.shields.io/opencollective/backers/sdkman)](#backers) +[![Sponsors on Open Collective](https://img.shields.io/opencollective/sponsors/sdkman)](#sponsors) +[![Discord](https://img.shields.io/discord/1245471991117512754)](https://discord.gg/y9mVJYVyu4) -SDKMAN is a tool for managing parallel Versions of multiple Software Development Kits on any Unix based system. It provides a convenient command line interface for installing, switching, removing and listing Candidates. +SDKMAN is a tool for managing parallel Versions of multiple Software Development Kits on any Unix-based system. It provides a convenient command-line interface for installing, switching, removing, and listing Candidates. See documentation on the [SDKMAN! website](https://sdkman.io). +## NOTICE + +**We are rewriting all the commands for SDKMAN! in [Rust](https://www.rust-lang.org/) under a [new project](https://github.com/sdkman/sdkman-cli-native) that supplements this one. Only bug fixes to supporting code will be +accepted in this project. As a result, no further enhancements will be accepted on the commands in this project, and the commands here will be phased out in due course. This project will eventually form a lightweight +wrapper/launcher for the replacement Rust commands.** + ## Installation Open your favourite terminal and enter the following: @@ -23,32 +29,9 @@ All SDKMAN's BDD tests describing the CLI behaviour are written in Cucumber and $ ./gradlew test -To perform development, you will need to have a JDK 8 or higher installed which can be obtained by running the following after installing SDKMAN: - - $ sdk install java - -### Using Docker for tests - -You can run the tests in a Docker container to guarantee a clean test environment. - - $ docker build --tag=sdkman-cli/gradle . - $ docker run --rm -it sdkman-cli/gradle test - -By running the following command, you don't need to wait for downloading Gradle wrapper and other dependencies. The test reports can be found under the local `build` directory. - - $ docker run --rm -it -v $PWD:/usr/src/app -v $HOME/.gradle:/root/.gradle sdkman-cli/gradle test - -### Local Installation - -To install SDKMAN locally running against your local server, run the following commands: - - $ ./gradlew install - $ source ~/.sdkman/bin/sdkman-init.sh - -Or run install locally with Production configuration: +To perform development, you will need to have a JDK 11 installed which can be obtained by running the following after installing SDKMAN: - $ ./gradlew -Penv=production install - $ source ~/.sdkman/bin/sdkman-init.sh + $ sdk env install ## Contributors diff --git a/bin/release-binary.sh b/bin/release-binary.sh index 647459945..eca3cb2c7 100755 --- a/bin/release-binary.sh +++ b/bin/release-binary.sh @@ -25,4 +25,9 @@ fi echo "Release: $FIELD as $VERSION" -mongo "${MONGO_URL}" --username="${MONGO_USERNAME}" --password="${MONGO_PASSWORD}" -eval "db.application.updateOne({}, {\$set: { \"$FIELD\": \"$VERSION\"}});" +docker run mongo:3.2 mongo "${MONGO_URL}" \ + --username="${MONGO_USERNAME}" \ + --password="${MONGO_PASSWORD}" \ + --quiet \ + --eval "db.application.updateOne({}, {\$set: { \"$FIELD\": \"$VERSION\"}});" + diff --git a/build.gradle b/build.gradle index 65cc50721..ab6588dec 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id('groovy') - id('org.jreleaser').version('0.8.0').apply(false) + id('org.jreleaser').version('1.4.0').apply(false) } String userHome = System.getProperty('user.home') diff --git a/contrib/completion/bash/sdk b/contrib/completion/bash/sdk index 17fc6e3ae..3ad18bc76 100644 --- a/contrib/completion/bash/sdk +++ b/contrib/completion/bash/sdk @@ -23,7 +23,7 @@ __sdkman_complete_command() { case $command in sdk) - candidates=("install" "uninstall" "list" "use" "config" "default" "home" "env" "current" "upgrade" "version" "broadcast" "help" "offline" "selfupdate" "update" "flush") + candidates=("install" "uninstall" "list" "use" "config" "default" "home" "env" "current" "upgrade" "version" "help" "offline" "selfupdate" "update" "flush") ;; current|c|default|d|home|h|uninstall|rm|upgrade|ug|use|u) local -r candidate_paths=("${SDKMAN_CANDIDATES_DIR}"/*) @@ -45,7 +45,7 @@ __sdkman_complete_command() { candidates=("force") ;; flush) - candidates=("archives" "temp" "broadcast" "version") + candidates=("temp" "version") ;; esac diff --git a/gradle/archive.gradle b/gradle/archive.gradle index 827529262..0c5baa0ce 100644 --- a/gradle/archive.gradle +++ b/gradle/archive.gradle @@ -10,7 +10,6 @@ task prepareBin(type: Copy) { filter( ReplaceTokens, tokens: [ - SDKMAN_VERSION : sdkmanVersion, SDKMAN_CANDIDATES_API: candidatesApi ] ) diff --git a/gradle/release.gradle b/gradle/release.gradle index 7d20c6a3d..8ba2202b9 100644 --- a/gradle/release.gradle +++ b/gradle/release.gradle @@ -34,14 +34,20 @@ jreleaser { distributionType = 'BINARY' artifact { path = "build/distributions/{{distributionName}}-${sdkmanVersion}.zip" + extraProperties.put("universal", "true") } } } - + announce { twitter { active = 'RELEASE' status = 'Released version {{tagName}} of SDKMAN! {{releaseNotesUrl}}' } + mastodon { + active = 'RELEASE' + status = 'Released version {{tagName}} of SDKMAN! {{releaseNotesUrl}}' + host = 'https://fosstodon.org' + } } } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2a563242c..f72df95a7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/bash/sdkman-availability.sh b/src/main/bash/sdkman-availability.sh index 7d755a276..696117b5e 100644 --- a/src/main/bash/sdkman-availability.sh +++ b/src/main/bash/sdkman-availability.sh @@ -16,26 +16,25 @@ # limitations under the License. # -function __sdkman_update_broadcast_and_service_availability() { - local broadcast_live_id=$(__sdkman_determine_broadcast_id) - __sdkman_set_availability "$broadcast_live_id" - __sdkman_update_broadcast "$broadcast_live_id" +function __sdkman_update_service_availability() { + local healthcheck_status=$(__sdkman_determine_healthcheck_status) + __sdkman_set_availability "$healthcheck_status" } -function __sdkman_determine_broadcast_id() { +function __sdkman_determine_healthcheck_status() { if [[ "$SDKMAN_OFFLINE_MODE" == "true" || "$COMMAND" == "offline" && "$QUALIFIER" == "enable" ]]; then echo "" else - echo $(__sdkman_secure_curl_with_timeouts "${SDKMAN_CANDIDATES_API}/broadcast/latest/id") + echo $(__sdkman_secure_curl_with_timeouts "${SDKMAN_CANDIDATES_API}/healthcheck") fi } function __sdkman_set_availability() { - local broadcast_id="$1" - local detect_html="$(echo "$broadcast_id" | tr '[:upper:]' '[:lower:]' | grep 'html')" - if [[ -z "$broadcast_id" ]]; then + local healthcheck_status="$1" + local detect_html="$(echo "$healthcheck_status" | tr '[:upper:]' '[:lower:]' | grep 'html')" + if [[ -z "$healthcheck_status" ]]; then SDKMAN_AVAILABLE="false" - __sdkman_display_offline_warning "$broadcast_id" + __sdkman_display_offline_warning "$healthcheck_status" elif [[ -n "$detect_html" ]]; then SDKMAN_AVAILABLE="false" __sdkman_display_proxy_warning @@ -45,8 +44,8 @@ function __sdkman_set_availability() { } function __sdkman_display_offline_warning() { - local broadcast_id="$1" - if [[ -z "$broadcast_id" && "$COMMAND" != "offline" && "$SDKMAN_OFFLINE_MODE" != "true" ]]; then + local healthcheck_status="$1" + if [[ -z "$healthcheck_status" && "$COMMAND" != "offline" && "$SDKMAN_OFFLINE_MODE" != "true" ]]; then __sdkman_echo_red "==== INTERNET NOT REACHABLE! ===================================================" __sdkman_echo_red "" __sdkman_echo_red " Some functionality is disabled or only partially available." @@ -65,32 +64,3 @@ function __sdkman_display_proxy_warning() { __sdkman_echo_red "================================================================================" echo "" } - -function __sdkman_update_broadcast() { - local broadcast_live_id broadcast_id_file broadcast_text_file broadcast_old_id - - broadcast_live_id="$1" - broadcast_id_file="${SDKMAN_DIR}/var/broadcast_id" - broadcast_text_file="${SDKMAN_DIR}/var/broadcast" - broadcast_old_id="" - - if [[ -f "$broadcast_id_file" ]]; then - broadcast_old_id=$(< "$broadcast_id_file") - fi - - if [[ -f "$broadcast_text_file" ]]; then - BROADCAST_OLD_TEXT=$(< "$broadcast_text_file") - fi - - if [[ "$SDKMAN_AVAILABLE" == "true" && "$broadcast_live_id" != "$broadcast_old_id" && "$COMMAND" != "selfupdate" && "$COMMAND" != "flush" ]]; then - mkdir -p "${SDKMAN_DIR}/var" - - echo "$broadcast_live_id" | tee "$broadcast_id_file" > /dev/null - - BROADCAST_LIVE_TEXT=$(__sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/broadcast/latest") - echo "$BROADCAST_LIVE_TEXT" | tee "$broadcast_text_file" > /dev/null - if [[ "$COMMAND" != "broadcast" ]]; then - __sdkman_echo_cyan "$BROADCAST_LIVE_TEXT" - fi - fi -} diff --git a/src/main/bash/sdkman-broadcast.sh b/src/main/bash/sdkman-broadcast.sh deleted file mode 100644 index a75902612..000000000 --- a/src/main/bash/sdkman-broadcast.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -# -# Copyright 2021 Marco Vermeulen -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -function __sdk_broadcast() { - if [ "$BROADCAST_OLD_TEXT" ]; then - __sdkman_echo_cyan "$BROADCAST_OLD_TEXT" - else - __sdkman_echo_cyan "$BROADCAST_LIVE_TEXT" - fi -} diff --git a/src/main/bash/sdkman-cache.sh b/src/main/bash/sdkman-cache.sh index b21d19043..fa28ffa20 100644 --- a/src/main/bash/sdkman-cache.sh +++ b/src/main/bash/sdkman-cache.sh @@ -18,48 +18,14 @@ function ___sdkman_check_candidates_cache() { local candidates_cache="$1" - if [[ -f "$candidates_cache" && -n "$(< "$candidates_cache")" && -n "$(find "$candidates_cache" -mmin +$((24 * 60 * 30)))" ]]; then - __sdkman_echo_yellow 'We periodically need to update the local cache. Please run:' - echo '' - __sdkman_echo_no_colour ' $ sdk update' - echo '' - return 0 - elif [[ -f "$candidates_cache" && -z "$(< "$candidates_cache")" ]]; then + if [[ -f "$candidates_cache" && -z "$(< "$candidates_cache")" ]]; then __sdkman_echo_red 'WARNING: Cache is corrupt. SDKMAN cannot be used until updated.' echo '' __sdkman_echo_no_colour ' $ sdk update' echo '' return 1 else - __sdkman_echo_debug "No update at this time. Using existing cache: $SDKMAN_CANDIDATES_CSV" + __sdkman_echo_debug "Using existing cache: $SDKMAN_CANDIDATES_CSV" return 0 fi } - -function ___sdkman_check_version_cache() { - local version_url - local version_file="${SDKMAN_DIR}/var/version" - - if [[ "$sdkman_beta_channel" != "true" && -f "$version_file" && -z "$(find "$version_file" -mmin +$((60 * 24)))" ]]; then - __sdkman_echo_debug "Not refreshing version cache now..." - SDKMAN_REMOTE_VERSION=$(cat "$version_file") - else - __sdkman_echo_debug "Version cache needs updating..." - if [[ "$sdkman_beta_channel" == "true" ]]; then - __sdkman_echo_debug "Refreshing version cache with BETA version." - version_url="${SDKMAN_CANDIDATES_API}/broker/download/sdkman/version/beta" - else - __sdkman_echo_debug "Refreshing version cache with STABLE version." - version_url="${SDKMAN_CANDIDATES_API}/broker/download/sdkman/version/stable" - fi - - SDKMAN_REMOTE_VERSION=$(__sdkman_secure_curl_with_timeouts "$version_url") - if [[ -z "$SDKMAN_REMOTE_VERSION" || -n "$(echo "$SDKMAN_REMOTE_VERSION" | tr '[:upper:]' '[:lower:]' | grep 'html')" ]]; then - __sdkman_echo_debug "Version information corrupt or empty! Ignoring: $SDKMAN_REMOTE_VERSION" - SDKMAN_REMOTE_VERSION="$SDKMAN_VERSION" - else - __sdkman_echo_debug "Overwriting version cache with: $SDKMAN_REMOTE_VERSION" - echo "${SDKMAN_REMOTE_VERSION}" | tee "$version_file" > /dev/null - fi - fi -} diff --git a/src/main/bash/sdkman-default.sh b/src/main/bash/sdkman-default.sh index 52d4ec612..a5470c099 100644 --- a/src/main/bash/sdkman-default.sh +++ b/src/main/bash/sdkman-default.sh @@ -17,6 +17,7 @@ # function __sdk_default() { + __sdkman_deprecation_notice "default" local candidate version candidate="$1" diff --git a/src/main/bash/sdkman-env-helpers.sh b/src/main/bash/sdkman-env-helpers.sh index 8dafd17ea..2b155a0ae 100644 --- a/src/main/bash/sdkman-env-helpers.sh +++ b/src/main/bash/sdkman-env-helpers.sh @@ -64,7 +64,7 @@ function __sdkman_determine_version() { version=$(__sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/candidates/default/${candidate}") fi - local validation_url="${SDKMAN_CANDIDATES_API}/candidates/validate/${candidate}/${version}/$(echo $SDKMAN_PLATFORM | tr '[:upper:]' '[:lower:]')" + local validation_url="${SDKMAN_CANDIDATES_API}/candidates/validate/${candidate}/${version}/${SDKMAN_PLATFORM}" VERSION_VALID=$(__sdkman_secure_curl "$validation_url") __sdkman_echo_debug "Validate $candidate $version for $SDKMAN_PLATFORM: $VERSION_VALID" __sdkman_echo_debug "Validation URL: $validation_url" diff --git a/src/main/bash/sdkman-env.sh b/src/main/bash/sdkman-env.sh index 5d2ce6589..28b541c65 100644 --- a/src/main/bash/sdkman-env.sh +++ b/src/main/bash/sdkman-env.sh @@ -54,10 +54,25 @@ function __sdkman_load_env() { return 1 fi - __sdkman_env_each_candidate "$sdkmanrc" "__sdk_use" && + __sdkman_env_each_candidate "$sdkmanrc" "__sdkman_check_and_use" && SDKMAN_ENV=$PWD } +function __sdkman_check_and_use() { + local -r candidate=$1 + local -r version=$2 + + if [[ ! -d "${SDKMAN_CANDIDATES_DIR}/${candidate}/${version}" ]]; then + __sdkman_echo_red "Stop! $candidate $version is not installed." + echo "" + __sdkman_echo_yellow "Run 'sdk env install' to install it." + + return 1 + fi + + __sdk_use "$candidate" "$version" +} + function __sdkman_create_env_file() { local sdkmanrc="$1" @@ -130,7 +145,7 @@ function __sdkman_env_each_candidate() { return 1 fi - $func "${normalised_line%=*}" "${normalised_line#*=}" + $func "${normalised_line%=*}" "${normalised_line#*=}" || return done < "$filepath" } diff --git a/src/main/bash/sdkman-flush.sh b/src/main/bash/sdkman-flush.sh index ee41ca217..f65ef282d 100644 --- a/src/main/bash/sdkman-flush.sh +++ b/src/main/bash/sdkman-flush.sh @@ -20,18 +20,12 @@ function __sdk_flush() { local qualifier="$1" case "$qualifier" in - broadcast) - __sdkman_cleanup_broadcast - ;; version) if [[ -f "${SDKMAN_DIR}/var/version" ]]; then rm -f "${SDKMAN_DIR}/var/version" __sdkman_echo_green "Version file has been flushed." fi ;; - archives) - __sdkman_cleanup_folder "archives" - ;; temp) __sdkman_cleanup_folder "tmp" ;; @@ -42,7 +36,6 @@ function __sdk_flush() { __sdkman_cleanup_folder "var/metadata" ;; *) - __sdkman_cleanup_folder "archives" __sdkman_cleanup_folder "tmp" __sdkman_cleanup_folder "var/metadata" ;; @@ -64,13 +57,3 @@ function __sdkman_cleanup_folder() { __sdkman_echo_green "${sdkman_cleanup_count} archive(s) flushed, freeing ${sdkman_cleanup_disk_usage}." } - -function __sdkman_cleanup_broadcast() { - if [[ -f "${SDKMAN_DIR}/var/broadcast_id" ]]; then - rm -f "${SDKMAN_DIR}/var/broadcast_id" - rm -f "${SDKMAN_DIR}/var/broadcast" - __sdkman_echo_green "Broadcast has been flushed." - else - __sdkman_echo_no_colour "No prior broadcast found so not flushed." - fi -} diff --git a/src/main/bash/sdkman-help.sh b/src/main/bash/sdkman-help.sh index 88eebfc6e..70bacc448 100644 --- a/src/main/bash/sdkman-help.sh +++ b/src/main/bash/sdkman-help.sh @@ -17,6 +17,7 @@ # function __sdk_help() { + __sdkman_deprecation_notice "help" __sdkman_echo_no_colour "" __sdkman_echo_no_colour "Usage: sdk [candidate] [version]" __sdkman_echo_no_colour " sdk offline " @@ -33,12 +34,15 @@ function __sdk_help() { __sdkman_echo_no_colour " current or c [candidate]" __sdkman_echo_no_colour " upgrade or ug [candidate]" __sdkman_echo_no_colour " version or v" - __sdkman_echo_no_colour " broadcast or b" __sdkman_echo_no_colour " help" __sdkman_echo_no_colour " offline [enable|disable]" - __sdkman_echo_no_colour " selfupdate [force]" + + if [[ "$sdkman_selfupdate_feature" == "true" ]]; then + __sdkman_echo_no_colour " selfupdate [force]" + fi + __sdkman_echo_no_colour " update" - __sdkman_echo_no_colour " flush [archives|tmp|broadcast|metadata|version]" + __sdkman_echo_no_colour " flush [tmp|metadata|version]" __sdkman_echo_no_colour "" __sdkman_echo_no_colour " candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc." __sdkman_echo_no_colour " use list command for comprehensive list of candidates" diff --git a/src/main/bash/sdkman-home.sh b/src/main/bash/sdkman-home.sh index 841d32bf6..e3e2b4755 100644 --- a/src/main/bash/sdkman-home.sh +++ b/src/main/bash/sdkman-home.sh @@ -17,6 +17,7 @@ # function __sdk_home() { + __sdkman_deprecation_notice "home" local candidate version candidate="$1" diff --git a/src/main/bash/sdkman-init.sh b/src/main/bash/sdkman-init.sh index 89ad27e84..7e8e34349 100644 --- a/src/main/bash/sdkman-init.sh +++ b/src/main/bash/sdkman-init.sh @@ -17,10 +17,6 @@ # # set env vars if not set -if [ -z "$SDKMAN_VERSION" ]; then - export SDKMAN_VERSION="@SDKMAN_VERSION@" -fi - if [ -z "$SDKMAN_CANDIDATES_API" ]; then export SDKMAN_CANDIDATES_API="@SDKMAN_CANDIDATES_API@" fi @@ -34,63 +30,8 @@ if [ -f "${SDKMAN_DIR}/etc/config" ]; then source "${SDKMAN_DIR}/etc/config" fi -# infer platform -function infer_platform() { - local kernel - local machine - - kernel="$(uname -s)" - machine="$(uname -m)" - - case $kernel in - Linux) - case $machine in - i686) - echo "LinuxX32" - ;; - x86_64) - echo "LinuxX64" - ;; - armv6l) - echo "LinuxARM32HF" - ;; - armv7l) - echo "LinuxARM32HF" - ;; - armv8l) - echo "LinuxARM32HF" - ;; - aarch64) - echo "LinuxARM64" - ;; - *) - echo "LinuxX64" - ;; - esac - ;; - Darwin) - case $machine in - x86_64) - echo "DarwinX64" - ;; - arm64) - if [[ "$sdkman_rosetta2_compatible" == 'true' ]]; then - echo "DarwinX64" - else - echo "DarwinARM64" - fi - ;; - *) - echo "DarwinX64" - ;; - esac - ;; - *) - echo "$kernel" - esac -} - -SDKMAN_PLATFORM="$(infer_platform | tr '[:upper:]' '[:lower:]')" +# Read the platform file +SDKMAN_PLATFORM="$(cat "${SDKMAN_DIR}/var/platform")" export SDKMAN_PLATFORM # OS specific support (must be 'true' or 'false'). @@ -225,8 +166,9 @@ if [[ "$sdkman_auto_env" == "true" ]]; then export SDKMAN_OLD_PWD="$PWD" } - - [[ -z "$PROMPT_COMMAND" ]] && PROMPT_COMMAND="sdkman_auto_env" || PROMPT_COMMAND="${PROMPT_COMMAND%\;};sdkman_auto_env" + + trimmed_prompt_command="${PROMPT_COMMAND%"${PROMPT_COMMAND##*[![:space:]]}"}" + [[ -z "$trimmed_prompt_command" ]] && PROMPT_COMMAND="sdkman_auto_env" || PROMPT_COMMAND="${trimmed_prompt_command%\;};sdkman_auto_env" fi sdkman_auto_env diff --git a/src/main/bash/sdkman-install.sh b/src/main/bash/sdkman-install.sh index 447464aa0..8c95fee96 100644 --- a/src/main/bash/sdkman-install.sh +++ b/src/main/bash/sdkman-install.sh @@ -70,7 +70,7 @@ function __sdkman_install_candidate_version() { mkdir -p "${SDKMAN_CANDIDATES_DIR}/${candidate}" rm -rf "${SDKMAN_DIR}/tmp/out" - unzip -oq "${SDKMAN_DIR}/archives/${candidate}-${version}.zip" -d "${SDKMAN_DIR}/tmp/out" + unzip -oq "${SDKMAN_DIR}/tmp/${candidate}-${version}.zip" -d "${SDKMAN_DIR}/tmp/out" mv -f "$SDKMAN_DIR"/tmp/out/* "${SDKMAN_CANDIDATES_DIR}/${candidate}/${version}" __sdkman_echo_green "Done installing!" echo "" @@ -114,66 +114,47 @@ function __sdkman_install_local_version() { } function __sdkman_download() { - local candidate version archives_folder - local headers_file tmp_headers_file + local candidate version candidate="$1" version="$2" - archives_folder="${SDKMAN_DIR}/archives" metadata_folder="${SDKMAN_DIR}/var/metadata" - mkdir -p ${metadata_folder} + mkdir -p "${metadata_folder}" - if [ ! -f "${archives_folder}/${candidate}-${version}.zip" ]; then - local platform_parameter="$(echo $SDKMAN_PLATFORM | tr '[:upper:]' '[:lower:]')" - local download_url="${SDKMAN_CANDIDATES_API}/broker/download/${candidate}/${version}/${platform_parameter}" - local base_name="${candidate}-${version}" - local zip_archive_target="${SDKMAN_DIR}/archives/${base_name}.zip" - tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp" - headers_file="${metadata_folder}/${base_name}.headers" - - # pre-installation hook: implements function __sdkman_pre_installation_hook - local pre_installation_hook="${SDKMAN_DIR}/tmp/hook_pre_${candidate}_${version}.sh" - __sdkman_echo_debug "Get pre-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/pre/${candidate}/${version}/${platform_parameter}" >| "$pre_installation_hook" - __sdkman_echo_debug "Copy remote pre-installation hook: $pre_installation_hook" - source "$pre_installation_hook" - __sdkman_pre_installation_hook || return 1 - __sdkman_echo_debug "Completed pre-installation hook..." - - export local binary_input="${SDKMAN_DIR}/tmp/${base_name}.bin" - export local zip_output="${SDKMAN_DIR}/tmp/$base_name.zip" + local platform_parameter="$SDKMAN_PLATFORM" + local download_url="${SDKMAN_CANDIDATES_API}/broker/download/${candidate}/${version}/${platform_parameter}" + local base_name="${candidate}-${version}" + local tmp_headers_file="${SDKMAN_DIR}/tmp/${base_name}.headers.tmp" + local headers_file="${metadata_folder}/${base_name}.headers" - echo "" - __sdkman_echo_no_colour "Downloading: ${candidate} ${version}" - echo "" - __sdkman_echo_no_colour "In progress..." - echo "" + export local binary_input="${SDKMAN_DIR}/tmp/${base_name}.bin" + export local zip_output="${SDKMAN_DIR}/tmp/${base_name}.zip" - # download binary - __sdkman_secure_curl_download "${download_url}" --output "${binary_input}" --dump-header "${tmp_headers_file}" - grep '^X-Sdkman' "${tmp_headers_file}" > "${headers_file}" - __sdkman_echo_debug "Downloaded binary to: ${binary_input} (HTTP headers written to: ${headers_file})" - - # post-installation hook: implements function __sdkman_post_installation_hook - # responsible for taking `binary_input` and producing `zip_output` - local post_installation_hook="${SDKMAN_DIR}/tmp/hook_post_${candidate}_${version}.sh" - __sdkman_echo_debug "Get post-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/post/${candidate}/${version}/${platform_parameter}" - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/post/${candidate}/${version}/${platform_parameter}" >| "$post_installation_hook" - __sdkman_echo_debug "Copy remote post-installation hook: ${post_installation_hook}" - source "$post_installation_hook" - __sdkman_post_installation_hook || return 1 - __sdkman_echo_debug "Processed binary as: $zip_output" - __sdkman_echo_debug "Completed post-installation hook..." - - mv -f "$zip_output" "$zip_archive_target" - __sdkman_echo_debug "Moved to archive folder: $zip_archive_target" - else - echo "" - __sdkman_echo_no_colour "Found a previously downloaded ${candidate} ${version} archive. Not downloading it again..." - fi - __sdkman_checksum_zip "${archives_folder}/${candidate}-${version}.zip" "${headers_file}" || return 1 - __sdkman_validate_zip "${archives_folder}/${candidate}-${version}.zip" || return 1 + echo "" + __sdkman_echo_no_colour "Downloading: ${candidate} ${version}" + echo "" + __sdkman_echo_no_colour "In progress..." + echo "" + + # download binary + __sdkman_secure_curl_download "${download_url}" --output "${binary_input}" --dump-header "${tmp_headers_file}" + grep '^X-Sdkman' "${tmp_headers_file}" > "${headers_file}" + __sdkman_echo_debug "Downloaded binary to: ${binary_input} (HTTP headers written to: ${headers_file})" + + # post-installation hook: implements function __sdkman_post_installation_hook + # responsible for taking `binary_input` and producing `zip_output` + local post_installation_hook="${SDKMAN_DIR}/tmp/hook_post_${candidate}_${version}.sh" + __sdkman_echo_debug "Get post-installation hook: ${SDKMAN_CANDIDATES_API}/hooks/post/${candidate}/${version}/${platform_parameter}" + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/hooks/post/${candidate}/${version}/${platform_parameter}" >| "$post_installation_hook" + __sdkman_echo_debug "Copy remote post-installation hook: ${post_installation_hook}" + source "$post_installation_hook" + __sdkman_post_installation_hook || return 1 + __sdkman_echo_debug "Processed binary as: $zip_output" + __sdkman_echo_debug "Completed post-installation hook..." + + __sdkman_validate_zip "${zip_output}" || return 1 + __sdkman_checksum_zip "${zip_output}" "${headers_file}" || return 1 echo "" } @@ -247,5 +228,5 @@ function __sdkman_checksum_zip() { __sdkman_echo_no_colour "Not able to perform checksum verification at this time." fi fi - done < ${headers_file} + done < "${headers_file}" } diff --git a/src/main/bash/sdkman-main.sh b/src/main/bash/sdkman-main.sh index d134231e2..5d592e9ee 100644 --- a/src/main/bash/sdkman-main.sh +++ b/src/main/bash/sdkman-main.sh @@ -16,6 +16,14 @@ # limitations under the License. # +function ___sdkman_help() { + if [[ -f "$SDKMAN_DIR/libexec/help" ]]; then + "$SDKMAN_DIR/libexec/help" + else + __sdk_help + fi +} + function sdk() { COMMAND="$1" @@ -49,9 +57,6 @@ function sdk() { d) COMMAND="default" ;; - b) - COMMAND="broadcast" - ;; h) COMMAND="home" ;; @@ -60,16 +65,6 @@ function sdk() { ;; esac - if [[ "$COMMAND" == "home" ]]; then - __sdk_home "$QUALIFIER" "$3" - return $? - fi - - # Left here for legacy purposes, issue #912 on Github - if [[ "$COMMAND" == "completion" ]]; then - return 0 - fi - # # Various sanity checks and default settings # @@ -78,8 +73,6 @@ function sdk() { if [[ "$COMMAND" != "update" ]]; then ___sdkman_check_candidates_cache "$SDKMAN_CANDIDATES_CACHE" || return 1 fi - # Check version cache - ___sdkman_check_version_cache # Always presume internet availability SDKMAN_AVAILABLE="true" @@ -88,7 +81,7 @@ function sdk() { fi # ...unless proven otherwise - __sdkman_update_broadcast_and_service_availability + __sdkman_update_service_availability # Load the sdkman config if it exists. if [ -f "${SDKMAN_DIR}/etc/config" ]; then @@ -97,15 +90,17 @@ function sdk() { # no command provided if [[ -z "$COMMAND" ]]; then - __sdk_help + ___sdkman_help return 1 fi # Check if it is a valid command CMD_FOUND="" - CMD_TARGET="${SDKMAN_DIR}/src/sdkman-${COMMAND}.sh" - if [[ -f "$CMD_TARGET" ]]; then - CMD_FOUND="$CMD_TARGET" + if [[ "$COMMAND" != "selfupdate" || "$sdkman_selfupdate_feature" == "true" ]]; then + CMD_TARGET="${SDKMAN_DIR}/src/sdkman-${COMMAND}.sh" + if [[ -f "$CMD_TARGET" ]]; then + CMD_FOUND="$CMD_TARGET" + fi fi # Check if it is a sourced function @@ -119,15 +114,7 @@ function sdk() { echo "" __sdkman_echo_red "Invalid command: $COMMAND" echo "" - __sdk_help - fi - - # Check whether the candidate exists - local sdkman_valid_candidate=$(echo ${SDKMAN_CANDIDATES[@]} | grep -w "$QUALIFIER") - if [[ -n "$QUALIFIER" && "$COMMAND" != "help" && "$COMMAND" != "offline" && "$COMMAND" != "flush" && "$COMMAND" != "selfupdate" && "$COMMAND" != "env" && "$COMMAND" != "completion" && "$COMMAND" != "edit" && -z "$sdkman_valid_candidate" ]]; then - echo "" - __sdkman_echo_red "Stop! $QUALIFIER is not a valid candidate." - return 1 + ___sdkman_help fi # Validate offline qualifier @@ -142,31 +129,24 @@ function sdk() { # Native commands found under libexec local native_command="${SDKMAN_DIR}/libexec/${COMMAND}" - # Internal commands use underscores rather than hyphens - local converted_command_name=$(echo "$COMMAND" | tr '-' '_') - - if [ -f "$native_command" ]; then - # Available as native command - if [ -z "$QUALIFIER" ]; then - "$native_command" - elif [ -z "$3" ]; then - "$native_command" "$QUALIFIER" - elif [ -z "$4" ]; then - "$native_command" "$QUALIFIER" "$3" - else - "$native_command" "$QUALIFIER" "$3" "$4" - fi - final_rc=$? + if [[ "$sdkman_native_enable" == 'true' && -f "$native_command" ]]; then + "$native_command" "${@:2}" elif [ -n "$CMD_FOUND" ]; then - # Available as a shell function - __sdk_"$converted_command_name" "$QUALIFIER" "$3" "$4" - final_rc=$? - fi - # Attempt upgrade after all is done - if [[ "$COMMAND" != "selfupdate" && "$sdkman_selfupdate_enable" == true ]]; then - __sdkman_auto_update "$SDKMAN_REMOTE_VERSION" "$SDKMAN_VERSION" + # Check whether the candidate exists + if [[ -n "$QUALIFIER" && "$COMMAND" != "help" && "$COMMAND" != "offline" && "$COMMAND" != "flush" && "$COMMAND" != "selfupdate" && "$COMMAND" != "env" && "$COMMAND" != "completion" && "$COMMAND" != "edit" && "$COMMAND" != "home" && -z $(echo ${SDKMAN_CANDIDATES[@]} | grep -w "$QUALIFIER") ]]; then + echo "" + __sdkman_echo_red "Stop! $QUALIFIER is not a valid candidate." + return 1 + fi + + # Internal commands use underscores rather than hyphens + local converted_command_name=$(echo "$COMMAND" | tr '-' '_') + + # Available as a shell function + __sdk_"$converted_command_name" "${@:2}" fi + final_rc=$? return $final_rc } diff --git a/src/main/bash/sdkman-selfupdate.sh b/src/main/bash/sdkman-selfupdate.sh index f262a5a6f..4cff93020 100644 --- a/src/main/bash/sdkman-selfupdate.sh +++ b/src/main/bash/sdkman-selfupdate.sh @@ -18,51 +18,38 @@ function __sdk_selfupdate() { local force_selfupdate + local sdkman_script_version_api + local sdkman_native_version_api - force_selfupdate="$1" if [[ "$SDKMAN_AVAILABLE" == "false" ]]; then echo "This command is not available while offline." - elif [[ "$SDKMAN_REMOTE_VERSION" == "$SDKMAN_VERSION" && "$force_selfupdate" != "force" ]]; then - echo "No update available at this time." - else - export sdkman_debug_mode - __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate" | bash + return 1 fi - unset SDKMAN_FORCE_SELFUPDATE -} - -function __sdkman_auto_update() { - local remote_version version delay_upgrade - - remote_version="$1" - version="$2" - delay_upgrade="${SDKMAN_DIR}/var/delay_upgrade" - - if [[ -n "$(find "$delay_upgrade" -mtime +1)" && "$remote_version" != "$version" ]]; then - echo "" - echo "" - __sdkman_echo_yellow "ATTENTION: A new version of SDKMAN is available..." - echo "" - __sdkman_echo_no_colour "The current version is $remote_version, but you have $version." - echo "" + if [[ "$sdkman_beta_channel" == "true" ]]; then + sdkman_script_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/beta" + sdkman_native_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/native/beta" + else + sdkman_script_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/script/stable" + sdkman_native_version_api="${SDKMAN_CANDIDATES_API}/broker/version/sdkman/native/stable" + fi - if [[ "$sdkman_auto_answer" == false ]]; then - __sdkman_echo_confirm "Would you like to upgrade now? (Y/n): " - read upgrade - fi + sdkman_remote_script_version=$(__sdkman_secure_curl "$sdkman_script_version_api") + sdkman_remote_native_version=$(__sdkman_secure_curl "$sdkman_native_version_api") - if [[ -z "$upgrade" ]]; then - upgrade="Y" - fi + sdkman_local_script_version=$(< "$SDKMAN_DIR/var/version") + sdkman_local_native_version=$(< "$SDKMAN_DIR/var/version_native") - if [[ "$upgrade" == "Y" || "$upgrade" == "y" ]]; then - __sdk_selfupdate - unset upgrade - else - __sdkman_echo_no_colour "Not upgrading today..." - fi + __sdkman_echo_debug "Script: local version: $sdkman_local_script_version; remote version: $sdkman_remote_script_version" + __sdkman_echo_debug "Native: local version: $sdkman_local_native_version; remote version: $sdkman_remote_native_version" - touch "$delay_upgrade" + force_selfupdate="$1" + export sdkman_debug_mode + if [[ "$sdkman_local_script_version" == "$sdkman_remote_script_version" && "$sdkman_local_native_version" == "$sdkman_remote_native_version" && "$force_selfupdate" != "force" ]]; then + echo "No update available at this time." + elif [[ "$sdkman_beta_channel" == "true" ]]; then + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/beta/${SDKMAN_PLATFORM}" | bash + else + __sdkman_secure_curl "${SDKMAN_CANDIDATES_API}/selfupdate/stable/${SDKMAN_PLATFORM}" | bash fi } diff --git a/src/main/bash/sdkman-uninstall.sh b/src/main/bash/sdkman-uninstall.sh index 16de6cfdd..c43e801b4 100644 --- a/src/main/bash/sdkman-uninstall.sh +++ b/src/main/bash/sdkman-uninstall.sh @@ -17,6 +17,7 @@ # function __sdk_uninstall() { + __sdkman_deprecation_notice "uninstall" local candidate version current candidate="$1" diff --git a/src/main/bash/sdkman-utils.sh b/src/main/bash/sdkman-utils.sh index 51797264f..397778d98 100644 --- a/src/main/bash/sdkman-utils.sh +++ b/src/main/bash/sdkman-utils.sh @@ -110,3 +110,19 @@ function __sdkman_echo_confirm() { echo -e -n "\033[1;33m$1\033[0m" fi } + +function __sdkman_deprecation_notice() { + local message=" +[Deprecation Notice]: +This legacy '$1' command is replaced by a native implementation +and it will be removed in a future release. +Please follow the discussion here: +https://github.com/sdkman/sdkman-cli/discussions/1332" + + if [[ "$sdkman_colour_enable" == 'false' ]]; then + __sdkman_echo_no_colour "$message" + else + __sdkman_echo_yellow "$message" + fi +} + diff --git a/src/main/bash/sdkman-version.sh b/src/main/bash/sdkman-version.sh index 6d4351ee8..640aa716f 100644 --- a/src/main/bash/sdkman-version.sh +++ b/src/main/bash/sdkman-version.sh @@ -17,6 +17,8 @@ # function __sdk_version() { + __sdkman_deprecation_notice "version" + local version=$(cat $SDKMAN_DIR/var/version) echo "" - __sdkman_echo_yellow "SDKMAN ${SDKMAN_VERSION}" + __sdkman_echo_yellow "SDKMAN $version" } diff --git a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy index e24b22be2..ab7058ad6 100644 --- a/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy +++ b/src/test/groovy/sdkman/env/SdkmanBashEnvBuilder.groovy @@ -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,21 +20,23 @@ class SdkmanBashEnvBuilder { private Optional curlStub = Optional.empty() private Optional unameStub = Optional.empty() private List candidates = ['groovy', 'grails', 'java'] + private String platform = UnixUtils.inferPlatform() private boolean offlineMode = false - private String broadcast = "This is a LIVE broadcast!" private String candidatesApi = "http://localhost:8080/2" - private String sdkmanVersion = "5.0.0" private String jdkHome = "/path/to/my/jdk" private String httpProxy - private String versionCache + private String scriptVersion + private String nativeVersion private boolean debugMode = true Map config = [ sdkman_auto_answer : 'false', - sdkman_beta_channel: 'false' + sdkman_beta_channel: 'false', + sdkman_native_enable: 'false', + sdkman_selfupdate_feature: 'true' ] - File sdkmanDir, sdkmanBinDir, sdkmanVarDir, sdkmanSrcDir, sdkmanEtcDir, sdkmanExtDir, sdkmanArchivesDir, + File sdkmanDir, sdkmanBinDir, sdkmanVarDir, sdkmanSrcDir, sdkmanEtcDir, sdkmanExtDir, sdkmanTmpDir, sdkmanCandidatesDir, sdkmanMetadataDir, sdkmanContribDir static SdkmanBashEnvBuilder create(File baseFolder) { @@ -53,14 +56,14 @@ class SdkmanBashEnvBuilder { this.unameStub = Optional.of(unameStub) this } - - SdkmanBashEnvBuilder withCandidates(List candidates) { - this.candidates = candidates + + SdkmanBashEnvBuilder withPlatform(String platform) { + this.platform = platform this } - SdkmanBashEnvBuilder withBroadcast(String broadcast) { - this.broadcast = broadcast + SdkmanBashEnvBuilder withCandidates(List candidates) { + this.candidates = candidates this } @@ -89,13 +92,13 @@ class SdkmanBashEnvBuilder { this } - SdkmanBashEnvBuilder withVersionCache(String version) { - this.versionCache = version + SdkmanBashEnvBuilder withScriptVersion(String version) { + this.scriptVersion = version this } - SdkmanBashEnvBuilder withSdkmanVersion(String version) { - this.sdkmanVersion = version + SdkmanBashEnvBuilder withNativeVersion(String version) { + this.nativeVersion = version this } @@ -111,7 +114,6 @@ class SdkmanBashEnvBuilder { sdkmanSrcDir = prepareDirectory(sdkmanDir, "src") sdkmanEtcDir = prepareDirectory(sdkmanDir, "etc") sdkmanExtDir = prepareDirectory(sdkmanDir, "ext") - sdkmanArchivesDir = prepareDirectory(sdkmanDir, "archives") sdkmanTmpDir = prepareDirectory(sdkmanDir, "tmp") sdkmanCandidatesDir = prepareDirectory(sdkmanDir, "candidates") sdkmanMetadataDir = prepareDirectory(sdkmanVarDir, "metadata") @@ -120,11 +122,12 @@ class SdkmanBashEnvBuilder { curlStub.map { it.build() } unameStub.map { it.build() } + initializeConfiguration(sdkmanEtcDir, config) initializeCandidates(sdkmanCandidatesDir, candidates) initializeCandidatesCache(sdkmanVarDir, candidates) - initializeBroadcast(sdkmanVarDir, broadcast) - initializeConfiguration(sdkmanEtcDir, config) - initializeVersionCache(sdkmanVarDir, versionCache) + initializePlatformDescriptor(sdkmanVarDir, platform) + initializeScriptVersionFile(sdkmanVarDir, scriptVersion) + initializeNativeVersionFile(sdkmanVarDir, nativeVersion) primeInitScript(sdkmanBinDir) primeModuleScripts(sdkmanSrcDir) @@ -135,7 +138,6 @@ class SdkmanBashEnvBuilder { SDKMAN_CANDIDATES_DIR: sdkmanCandidatesDir.absolutePath, SDKMAN_OFFLINE_MODE : "$offlineMode", SDKMAN_CANDIDATES_API: candidatesApi, - SDKMAN_VERSION : sdkmanVersion, sdkman_debug_mode : Boolean.toString(debugMode), JAVA_HOME : jdkHome ] @@ -153,12 +155,17 @@ class SdkmanBashEnvBuilder { directory } - private initializeVersionCache(File folder, String version) { + private initializeScriptVersionFile(File folder, String version) { if (version) { new File(folder, "version") << version } } + private initializeNativeVersionFile(File folder, String version) { + if (version) { + new File(folder, "version_native") << version + } + } private initializeCandidates(File folder, List candidates) { candidates.each { candidate -> @@ -174,9 +181,10 @@ class SdkmanBashEnvBuilder { candidatesCache << "" } } - - private initializeBroadcast(File targetFolder, String broadcast) { - new File(targetFolder, "broadcast") << broadcast + + private initializePlatformDescriptor(File folder, String platform) { + def platformDescriptor = new File(folder, "platform") + platformDescriptor << platform } private initializeConfiguration(File targetFolder, Map config) { diff --git a/src/test/groovy/sdkman/specs/BetaChannelBootstrapSpec.groovy b/src/test/groovy/sdkman/specs/BetaChannelBootstrapSpec.groovy deleted file mode 100644 index e378d877f..000000000 --- a/src/test/groovy/sdkman/specs/BetaChannelBootstrapSpec.groovy +++ /dev/null @@ -1,104 +0,0 @@ -package sdkman.specs - -import sdkman.support.SdkmanEnvSpecification - -class BetaChannelBootstrapSpec extends SdkmanEnvSpecification { - - static final TWO_DAYS_AGO = System.currentTimeMillis() - (48 * 60 * 60 * 1000) - static final CANDIDATES_API = "http://localhost:8080/2" - static final CLI_STABLE_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" - static final CLI_BETA_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/beta" - - File versionCache - - def setup() { - versionCache = new File("${sdkmanDotDirectory}/var", "version") - sdkmanBashEnvBuilder.withCandidates(["groovy"]) - } - - void "should attempt immediate upgrade of stable to beta version if beta channel is first enabled"() { - given: - def betaVersion = "x.y.c" - curlStub.primeWith(CLI_BETA_ENDPOINT, "echo $betaVersion") - bash = sdkmanBashEnvBuilder - .withConfiguration("sdkman_beta_channel", "true") - .withVersionCache("x.y.b") - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains(betaVersion) - } - - void "should attempt downgrade of beta to stable version if beta channel is first disabled"() { - given: - def stableVersion = "x.y.b" - curlStub.primeWith(CLI_STABLE_ENDPOINT, "echo $stableVersion") - bash = sdkmanBashEnvBuilder - .withConfiguration("sdkman_beta_channel", "false") - .withVersionCache("x.y.c") - .build() - versionCache.setLastModified(TWO_DAYS_AGO) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains(stableVersion) - } - - void "should attempt immediate upgrade to new version of beta channel if available"() { - given: - def newerBetaVersion = "x.y.d" - curlStub.primeWith(CLI_BETA_ENDPOINT, "echo $newerBetaVersion") - bash = sdkmanBashEnvBuilder - .withConfiguration("sdkman_beta_channel", "true") - .withVersionCache("x.y.c") - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains(newerBetaVersion) - } - - void "should attempt upgrade to new version of stable channel if available"() { - given: - def newerStableVersion = "x.y.d" - curlStub.primeWith(CLI_STABLE_ENDPOINT, "echo $newerStableVersion") - bash = sdkmanBashEnvBuilder - .withConfiguration("sdkman_beta_channel", "false") - .withVersionCache("x.y.c") - .build() - versionCache.setLastModified(TWO_DAYS_AGO) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains(newerStableVersion) - } -} diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateFailureSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateFailureSpec.groovy index 5f2eef230..d51c208bf 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateFailureSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateFailureSpec.groovy @@ -6,14 +6,14 @@ class CandidatesCacheUpdateFailureSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" + static final String HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" static final String CANDIDATES_ALL_ENDPOINT = "$CANDIDATES_API/candidates/all" File candidatesCache def setup() { candidatesCache = new File("${sdkmanDotDirectory}/var", "candidates") - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(HEALTHCHECK_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") .primeWith(CANDIDATES_ALL_ENDPOINT, "echo html") sdkmanBashEnvBuilder.withConfiguration("sdkman_debug_mode", "true") } diff --git a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy index f7120091b..0e52b1487 100644 --- a/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy +++ b/src/test/groovy/sdkman/specs/CandidatesCacheUpdateSpec.groovy @@ -6,14 +6,14 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" + static final String HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" static final String CANDIDATES_ALL_ENDPOINT = "$CANDIDATES_API/candidates/all" File candidatesCache def setup() { candidatesCache = new File("${sdkmanDotDirectory}/var", "candidates") - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(HEALTHCHECK_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") .primeWith(CANDIDATES_ALL_ENDPOINT, "echo groovy,scala") sdkmanBashEnvBuilder.withConfiguration("sdkman_debug_mode", "true") } @@ -39,48 +39,21 @@ class CandidatesCacheUpdateSpec extends SdkmanEnvSpecification { !bash.output.contains("SDKMAN 5.0.0") } - void "should issue a warning if cache is older than a month"() { + void "should log a success message if cache exists"() { given: bash = sdkmanBashEnvBuilder .withCandidates(['groovy']) .build() - and: - candidatesCache.setLastModified(((new Date() - 31) as Date).time) - and: bash.start() when: bash.execute("source $bootstrapScript") - bash.execute("sdk version") + bash.execute("sdk help") then: - bash.output.contains('We periodically need to update the local cache.') - bash.output.contains('$ sdk update') - - and: - bash.output.contains('SDKMAN 5.0.0') - } - - void "should log a success message in debug mode when no update needed"() { - given: - bash = sdkmanBashEnvBuilder - .withCandidates(['groovy']) - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - bash.output.contains('No update at this time. Using existing cache') - - and: - bash.output.contains('SDKMAN 5.0.0') + bash.output.contains('Using existing cache') } void "should bypass cache check if update command issued"() { diff --git a/src/test/groovy/sdkman/specs/CompletionSpec.groovy b/src/test/groovy/sdkman/specs/CompletionSpec.groovy index 7ef0eb04b..6e5017a4d 100644 --- a/src/test/groovy/sdkman/specs/CompletionSpec.groovy +++ b/src/test/groovy/sdkman/specs/CompletionSpec.groovy @@ -4,7 +4,6 @@ import sdkman.support.SdkmanEnvSpecification class CompletionSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" def "should complete the list of commands"() { given: @@ -20,7 +19,7 @@ class CompletionSpec extends SdkmanEnvSpecification { bash.execute('echo "\${COMPREPLY[@]}"') then: - bash.output.contains("install uninstall list use config default home env current upgrade version broadcast help offline selfupdate update flush") + bash.output.contains("install uninstall list use config default home env current upgrade version help offline selfupdate update flush") } def "should complete the list of candidates"() { @@ -43,14 +42,14 @@ class CompletionSpec extends SdkmanEnvSpecification { def "should complete the list of Java versions"() { given: - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") - .primeWith("$CANDIDATES_API/candidates/java/darwinx64/versions/all", "echo 16.0.1.hs-adpt,17.0.0-tem") + curlStub.primeWith("$CANDIDATES_API/candidates/java/darwinx64/versions/all", "echo 16.0.1.hs-adpt,17.0.0-tem") unameStub.forKernel("Darwin").forMachine("x86_64") bash = sdkmanBashEnvBuilder .withConfiguration("sdkman_auto_complete", "true") .withUnameStub(unameStub) + .withPlatform("darwinx64") .build() bash.start() diff --git a/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy b/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy index 384c0a11f..6c1d5a511 100644 --- a/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy @@ -6,7 +6,6 @@ class ConfigCommandSpec extends SdkmanEnvSpecification { def "it should open the config in the system's default editor"() { given: bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .build() diff --git a/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy b/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy index c1fcd1e96..9b88fa0c5 100644 --- a/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/CurrentCommandSpec.groovy @@ -9,10 +9,10 @@ import static java.nio.file.Files.createSymbolicLink class CurrentCommandSpec extends SdkmanEnvSpecification { static final CANDIDATES_API = "http://localhost:8080/2" - static final BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" + static final HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" def setup() { - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(HEALTHCHECK_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") } void "should display current version of all candidates installed"() { @@ -41,7 +41,6 @@ class CurrentCommandSpec extends SdkmanEnvSpecification { bash = sdkmanBashEnvBuilder .withOfflineMode(false) - .withVersionCache("5.0.0") .withCandidates(installedCandidates.keySet().toList()) .build() diff --git a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy index eb8344053..a71dd656a 100644 --- a/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/EnvCommandSpec.groovy @@ -9,19 +9,16 @@ import static java.nio.file.Files.createSymbolicLink class EnvCommandSpec extends SdkmanEnvSpecification { static final String CANDIDATES_API = "http://localhost:8080/2" - static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" static final String CANDIDATES_DEFAULT_JAVA = "$CANDIDATES_API/candidates/default/java" def "should generate .sdkmanrc when called with 'init'"() { given: - curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") - .primeWith(CANDIDATES_DEFAULT_JAVA, "echo 11.0.6.hs-adpt") + curlStub.primeWith(CANDIDATES_DEFAULT_JAVA, "echo 11.0.6.hs-adpt") setupCandidates(candidatesDirectory) bash = sdkmanBashEnvBuilder .withOfflineMode(true) - .withVersionCache("x.y.z") .build() bash.start() @@ -63,7 +60,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .build() @@ -100,7 +96,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", sdkmanAutoEnv) .build() @@ -135,7 +130,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -166,7 +160,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -193,7 +186,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -227,7 +219,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { createSymbolicLink(Paths.get("$candidatesDirectory/groovy/current"), Paths.get("$candidatesDirectory/groovy/2.4.6")) bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -266,7 +257,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { createSymbolicLink(Paths.get("$candidatesDirectory/ant/current"), Paths.get("$candidatesDirectory/ant/1.10.8")) bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -314,7 +304,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .withConfiguration("sdkman_auto_env", "true") .build() @@ -340,7 +329,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { def "should issue an error if .sdkmanrc contains a malformed candidate version"() { given: bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .build() @@ -359,6 +347,28 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } } + def "should issue an error when .sdkmanrc contains a candidate version which is not installed"() { + given: + bash = sdkmanBashEnvBuilder + .withOfflineMode(true) + .build() + + new File(bash.workDir, ".sdkmanrc").text = "groovy=2.4.1" + + bash.start() + bash.execute("source $bootstrapScript") + + when: + bash.execute("sdk env") + + then: + verifyAll(bash) { + status == 1 + output.contains("Stop! groovy 2.4.1 is not installed.") + output.contains("Run 'sdk env install' to install it.") + } + } + def "should support blank lines, comments and inline comments"() { given: new FileTreeBuilder(candidatesDirectory).with { @@ -368,7 +378,6 @@ class EnvCommandSpec extends SdkmanEnvSpecification { } bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") .withOfflineMode(true) .build() diff --git a/src/test/groovy/sdkman/specs/InitialisationSpec.groovy b/src/test/groovy/sdkman/specs/InitialisationSpec.groovy index f49b0da80..407f67a13 100644 --- a/src/test/groovy/sdkman/specs/InitialisationSpec.groovy +++ b/src/test/groovy/sdkman/specs/InitialisationSpec.groovy @@ -15,7 +15,6 @@ class InitialisationSpec extends SdkmanEnvSpecification { def setup() { bash = sdkmanBashEnvBuilder .withCandidates(allCandidates) - .withVersionCache("x.y.z") .build() prepareCandidateDirectories(allCandidates) } diff --git a/src/test/groovy/sdkman/specs/PlatformSpec.groovy b/src/test/groovy/sdkman/specs/PlatformSpec.groovy deleted file mode 100644 index a736a2939..000000000 --- a/src/test/groovy/sdkman/specs/PlatformSpec.groovy +++ /dev/null @@ -1,54 +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" | "" | "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"() { - 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") - } -} diff --git a/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy b/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy index cb5ba7bfc..00de66d1c 100644 --- a/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy +++ b/src/test/groovy/sdkman/specs/SdkCompatibilitySpec.groovy @@ -12,7 +12,6 @@ class SdkCompatibilitySpec extends SdkmanEnvSpecification { def setup() { bash = sdkmanBashEnvBuilder .withCandidates(allCandidates) - .withVersionCache("x.y.z") .build() } diff --git a/src/test/groovy/sdkman/specs/SelfupdateFeatureSpec.groovy b/src/test/groovy/sdkman/specs/SelfupdateFeatureSpec.groovy new file mode 100644 index 000000000..a5738c363 --- /dev/null +++ b/src/test/groovy/sdkman/specs/SelfupdateFeatureSpec.groovy @@ -0,0 +1,60 @@ +package sdkman.specs + +import sdkman.support.SdkmanEnvSpecification + +import java.time.Instant + +import static java.time.temporal.ChronoUnit.DAYS + +class SelfupdateFeatureSpec extends SdkmanEnvSpecification { + static final String CANDIDATES_API = "http://localhost:8080/2" + static final String HEALTHCHECK_ENDPOINT = "$CANDIDATES_API/healthcheck" + static final String VERSION_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" + + def setup() { + curlStub.primeWith(HEALTHCHECK_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") + curlStub.primeWith(VERSION_ENDPOINT, "echo 5.0.0") + } + + def "should list selfupdate as a valid command when the selfupdate feature is toggled on"() { + given: + bash = sdkmanBashEnvBuilder + .withConfiguration("sdkman_selfupdate_feature", selfUpdateFeature) + .build() + + bash.start() + bash.execute("source $bootstrapScript") + + when: + bash.execute("sdk help") + + then: + verifyOutput(bash.output) + + where: + selfUpdateFeature | verifyOutput + "false" | { !it.contains("selfupdate") } + "true" | { it.contains("selfupdate") } + } + + def "should source sdkman-selfupdate.sh when the selfupdate feature is toggled on"() { + given: + bash = sdkmanBashEnvBuilder + .withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) + .build() + + bash.start() + bash.execute("source $bootstrapScript") + + when: + bash.execute("sdk selfupdate") + + then: + verifyOutput(bash.output) + + where: + selfupdateFeature | verifyOutput + "false" | { it.contains("Invalid command: selfupdate") } + "true" | { !it.contains("Invalid command: selfupdate") } + } +} diff --git a/src/test/groovy/sdkman/specs/VersionCacheBootstrapSpec.groovy b/src/test/groovy/sdkman/specs/VersionCacheBootstrapSpec.groovy deleted file mode 100644 index f24605ce2..000000000 --- a/src/test/groovy/sdkman/specs/VersionCacheBootstrapSpec.groovy +++ /dev/null @@ -1,164 +0,0 @@ -package sdkman.specs - -import sdkman.support.SdkmanEnvSpecification - -import static java.lang.System.currentTimeMillis - -class VersionCacheBootstrapSpec extends SdkmanEnvSpecification { - - static final MORE_THAN_A_DAY_IN_MILLIS = 24 * 61 * 60 * 1000 - - static final CANDIDATES_API = "http://localhost:8080/2" - static final CLI_VERSION_STABLE_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" - static final CLI_VERSION_BETA_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/beta" - static final CANDIDATES_ENDPOINT = "$CANDIDATES_API/candidates" - - File versionCache - - def setup() { - versionCache = new File("${sdkmanDotDirectory}/var", "version") - curlStub.primeWith(CANDIDATES_ENDPOINT, "echo 'groovy,scala'") - } - - void "should store version cache if does not exist"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo x.y.b") - bash = sdkmanBashEnvBuilder.build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains("x.y.b") - } - - void "should not query server if unexpired version cache is found"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "sleep 50") //will timeout and fail if called - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains("x.y.z") - } - - void "should refresh version cache if older than a day"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo x.y.b") - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.a") - .build() - - and: - versionCache.setLastModified(currentTimeMillis() - MORE_THAN_A_DAY_IN_MILLIS) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains("x.y.b") - } - - void "should fallback and ignore version if version cache expired and api is offline"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo ''") - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") - .build() - - and: - versionCache.setLastModified(currentTimeMillis() - MORE_THAN_A_DAY_IN_MILLIS) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.text.contains("x.y.z") - } - - void "should not go offline if curl times out"() { - given: - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo ''") - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.z") - .build() - - and: - versionCache.setLastModified(currentTimeMillis() - MORE_THAN_A_DAY_IN_MILLIS) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - !bash.output.contains("SDKMAN can't reach the internet so going offline.") - } - - void "should ignore version if api returns garbage"() { - given: - def sdkmanVersion = "x.y.z" - curlStub.primeWith(CLI_VERSION_STABLE_ENDPOINT, "echo 'sorry'") - bash = sdkmanBashEnvBuilder - .withVersionCache(sdkmanVersion) - .build() - - and: - versionCache.setLastModified(currentTimeMillis() - MORE_THAN_A_DAY_IN_MILLIS) - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.text.contains(sdkmanVersion) - } - - void "should always refresh version cache if on beta_channel"() { - given: - curlStub.primeWith(CLI_VERSION_BETA_ENDPOINT, "echo x.y.z") - bash = sdkmanBashEnvBuilder - .withVersionCache("x.y.w") - .withConfiguration("sdkman_beta_channel", "true") - .build() - - and: - bash.start() - - when: - bash.execute("source $bootstrapScript") - bash.execute("sdk version") - - then: - versionCache.exists() - versionCache.text.contains("x.y.z") - } -} diff --git a/src/test/groovy/sdkman/steps/broadcast_steps.groovy b/src/test/groovy/sdkman/steps/broadcast_steps.groovy deleted file mode 100644 index 1700441b4..000000000 --- a/src/test/groovy/sdkman/steps/broadcast_steps.groovy +++ /dev/null @@ -1,29 +0,0 @@ -package sdkman.steps - -import static cucumber.api.groovy.EN.And -import static sdkman.stubs.WebServiceStub.primeEndpointWithString - -And(~'^no prior Broadcast was received$') { -> - broadcastFile.delete() - broadcastIdFile.delete() -} - -And(~'^a new Broadcast "(.*)" with id "(.*)" is available$') { String broadcast, String id -> - primeEndpointWithString("/broadcast/latest/id", id) - primeEndpointWithString("/broadcast/latest", broadcast) -} - -And(~'^a prior Broadcast "(.*)" with id "(.*)" was issued$') { String broadcast, String id -> - broadcastIdFile.write id - broadcastFile.write broadcast -} - -And(~'^no broadcast message can be found$') { -> - assert !broadcastIdFile.exists() - assert !broadcastFile.exists() -} - -And(~'^the broadcast has been flushed$') { -> - broadcastIdFile.delete() - broadcastFile.delete() -} diff --git a/src/test/groovy/sdkman/steps/env.groovy b/src/test/groovy/sdkman/steps/env.groovy index 3de259937..5d42daf91 100644 --- a/src/test/groovy/sdkman/steps/env.groovy +++ b/src/test/groovy/sdkman/steps/env.groovy @@ -19,8 +19,8 @@ counter = "${(Math.random() * 10000).toInteger()}".padLeft(4, "0") localGroovyCandidate = "/tmp/groovy-core" as File -sdkmanVersion = "5.0.0" -sdkmanVersionOutdated = "4.0.0" +sdkmanScriptVersion = "5.0.0" +sdkmanNativeVersion = "0.0.1" sdkmanBaseEnv = FilesystemUtils.prepareBaseDir().absolutePath sdkmanBaseDir = sdkmanBaseEnv as File @@ -34,11 +34,9 @@ varDir = "${sdkmanDirEnv}/var" as File metadataDir = "${varDir}/metadata" as File etcDir = "${sdkmanDirEnv}/etc" as File extDir = "${sdkmanDirEnv}/ext" as File -archiveDir = "${sdkmanDirEnv}/archives" as File tmpDir = "${sdkmanDir}/tmp" as File -broadcastFile = new File(varDir, "broadcast") -broadcastIdFile = new File(varDir, "broadcast_id") +healthcheckFile = new File(varDir, "healthcheck") candidatesFile = new File(varDir, "candidates") versionFile = new File(varDir, "version") initScript = new File(binDir, "sdkman-init.sh") diff --git a/src/test/groovy/sdkman/steps/flush_steps.groovy b/src/test/groovy/sdkman/steps/flush_steps.groovy index 4cdc3547c..928cabb52 100644 --- a/src/test/groovy/sdkman/steps/flush_steps.groovy +++ b/src/test/groovy/sdkman/steps/flush_steps.groovy @@ -1,8 +1,5 @@ package sdkman.steps -import java.nio.file.Files -import java.nio.file.Paths - import static cucumber.api.groovy.EN.And And(~'^the candidate "([^"]*)" is known locally$') { String candidate -> @@ -13,16 +10,6 @@ And(~'^no candidates are know locally$') { -> assert !candidatesFile.exists() } -And(~'^the archive "([^"]*)" has been cached$') { String archive -> - Files.copy( - Paths.get("src/test/resources/__files", archive), - Paths.get(archiveDir.getAbsolutePath(), archive)) -} - -And(~'^no archives are cached$') { -> - assert !archiveDir.listFiles() -} - And(~'^the file "([^"]*)" in temporary storage$') { String fileName -> new File(tmpDir, fileName).createNewFile() } diff --git a/src/test/groovy/sdkman/steps/initialisation_steps.groovy b/src/test/groovy/sdkman/steps/initialisation_steps.groovy index f676638ee..342e49aee 100644 --- a/src/test/groovy/sdkman/steps/initialisation_steps.groovy +++ b/src/test/groovy/sdkman/steps/initialisation_steps.groovy @@ -10,8 +10,6 @@ import static cucumber.api.groovy.EN.And import static sdkman.stubs.WebServiceStub.primeEndpointWithString import static sdkman.stubs.WebServiceStub.primeSelfupdate -def BROADCAST_MESSAGE = "broadcast message" - And(~'^the sdkman work folder is created$') { -> assert sdkmanDir.isDirectory(), "The SDKMAN directory does not exist." } @@ -30,14 +28,16 @@ And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is corrupt$') { Str } And(~'^the archive for candidate "([^"]*)" version "([^"]*)" is removed$') { String candidate, String version -> - def archive = new File("${sdkmanDir}/archives/${candidate}-${version}.zip") + def archive = new File("${sdkmanDir}/tmp/${candidate}-${version}.zip") assert !archive.exists() } +And(~'^the sdkman (.*) version "(.*)" is available for download$') { format, version -> + primeEndpointWithString("/broker/version/sdkman/${format}/stable", version) +} + And(~'^the internet is reachable$') { -> - primeEndpointWithString("/broadcast/latest/id", "12345") - primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE) - primeEndpointWithString("/app/stable", sdkmanVersion) + primeEndpointWithString("/healthcheck", "12345") primeSelfupdate() offlineMode = false @@ -52,9 +52,7 @@ And(~'^the internet is not reachable$') { -> } And(~'^offline mode is disabled with reachable internet$') { -> - primeEndpointWithString("/broadcast/latest/id", "12345") - primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE) - primeEndpointWithString("/app/stable", sdkmanVersion) + primeEndpointWithString("/healthcheck", "12345") offlineMode = false serviceUrlEnv = SERVICE_UP_URL @@ -62,9 +60,7 @@ And(~'^offline mode is disabled with reachable internet$') { -> } And(~'^offline mode is enabled with reachable internet$') { -> - primeEndpointWithString("/broadcast/latest/id", "12345") - primeEndpointWithString("/broadcast/latest", BROADCAST_MESSAGE) - primeEndpointWithString("/app/stable", sdkmanVersion) + primeEndpointWithString("/healthcheck", "12345") offlineMode = true serviceUrlEnv = SERVICE_UP_URL @@ -91,9 +87,9 @@ And(~'^an initialised environment$') { -> .withCandidatesApi(serviceUrlEnv) .withJdkHome(javaHome) .withHttpProxy(HTTP_PROXY) - .withVersionCache(sdkmanVersion) + .withScriptVersion(sdkmanScriptVersion) + .withNativeVersion(sdkmanNativeVersion) .withCandidates(localCandidates) - .withSdkmanVersion(sdkmanVersion) .build() } @@ -103,36 +99,13 @@ And(~'^an initialised environment without debug prints$') { -> .withCandidatesApi(serviceUrlEnv) .withJdkHome(javaHome) .withHttpProxy(HTTP_PROXY) - .withVersionCache(sdkmanVersion) + .withScriptVersion(sdkmanScriptVersion) + .withNativeVersion(sdkmanNativeVersion) .withCandidates(localCandidates) - .withSdkmanVersion(sdkmanVersion) .withDebugMode(false) .build() } -And(~'^an outdated initialised environment$') { -> - bash = SdkmanBashEnvBuilder.create(sdkmanBaseDir) - .withOfflineMode(offlineMode) - .withCandidatesApi(serviceUrlEnv) - .withJdkHome(javaHome) - .withHttpProxy(HTTP_PROXY) - .withVersionCache(sdkmanVersionOutdated) - .withSdkmanVersion(sdkmanVersionOutdated) - .build() - - def twoDaysAgoInMillis = System.currentTimeMillis() - 172800000 - - def upgradeFile = "$sdkmanDir/var/delay_upgrade" as File - upgradeFile.createNewFile() - upgradeFile.setLastModified(twoDaysAgoInMillis) - - def versionFile = "$sdkmanDir/var/version" as File - versionFile.setLastModified(twoDaysAgoInMillis) - - def initFile = "$sdkmanDir/bin/sdkman-init.sh" as File - initFile.text = initFile.text.replace(sdkmanVersion, sdkmanVersionOutdated) -} - And(~'^the system is bootstrapped$') { -> bash.start() bash.execute("source $sdkmanDirEnv/bin/sdkman-init.sh") @@ -142,8 +115,12 @@ And(~'^the system is bootstrapped again$') { -> bash.execute("source $sdkmanDirEnv/bin/sdkman-init.sh") } -And(~/^the sdkman version is "([^"]*)"$/) { String version -> - sdkmanVersion = version +And(~/^the sdkman scripts version is "([^"]*)"$/) { String version -> + sdkmanScriptVersion = version +} + +And(~/^the sdkman native version is "([^"]*)"$/) { String version -> + sdkmanNativeVersion = version } And(~/^the candidates cache is initialised with "(.*)"$/) { String candidate -> diff --git a/src/test/groovy/sdkman/steps/stub_steps.groovy b/src/test/groovy/sdkman/steps/stub_steps.groovy index f2508574b..f2594366c 100644 --- a/src/test/groovy/sdkman/steps/stub_steps.groovy +++ b/src/test/groovy/sdkman/steps/stub_steps.groovy @@ -12,18 +12,17 @@ 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, UnixUtils.inferPlatform()) - primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess()) primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess()) } -And(~'^an available selfupdate$') { -> - primeEndpointWithString("/selfupdate", 'echo "Successfully upgraded SDKMAN."') +And(~'^an available selfupdate endpoint$') { -> + primeEndpointWithString("/selfupdate/stable/${UnixUtils.inferPlatform()}", 'echo "Successfully upgraded SDKMAN."') + primeEndpointWithString("/selfupdate/beta/${UnixUtils.inferPlatform()}", 'echo "Successfully upgraded SDKMAN."') } And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download$') { String candidate, String version -> primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.inferPlatform()}", "valid") primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.inferPlatform()) - primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess()) primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess()) } @@ -31,20 +30,17 @@ And(~'^the candidate "([^"]*)" version "([^"]*)" is available for download with String candidate, String version, String checksum, String algorithm -> primeEndpointWithString("/candidates/validate/${candidate}/${version}/${UnixUtils.inferPlatform()}", "valid") primeDownloadFor(SERVICE_UP_URL, candidate, version, UnixUtils.inferPlatform(), ["X-Sdkman-Checksum-${algorithm}": "${checksum}"]) - primeEndpointWithString("/hooks/pre/${candidate}/${version}/${UnixUtils.inferPlatform()}", preInstallationHookSuccess()) primeEndpointWithString("/hooks/post/${candidate}/${version}/${UnixUtils.inferPlatform()}", postInstallationHookSuccess()) } -And(~/^the appropriate universal hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String os -> +And(~/^the appropriate universal hook is available for "([^"]*)" version "([^"]*)" on "([^"]*)"$/) { String candidate, String version, String os -> String lcPlatform = UnixUtils.inferPlatform(os) - primeUniversalHookFor("pre", candidate, version, lcPlatform) - primeUniversalHookFor("post", candidate, version, lcPlatform) + primeUniversalHookFor(candidate, version, lcPlatform) } -And(~/^the appropriate multi-platform hooks are available for "([^"]*)" version "([^"]*)" on "([^"]*)" with architecture "(.*)"$/) { String candidate, String version, String os, String architecture -> +And(~/^the appropriate multi-platform hook is available for "([^"]*)" version "([^"]*)" on "([^"]*)" with architecture "(.*)"$/) { String candidate, String version, String os, String architecture -> String lcPlatform = UnixUtils.inferPlatform(os, architecture) - primePlatformSpecificHookFor("pre", candidate, version, lcPlatform) - primePlatformSpecificHookFor("post", candidate, version, lcPlatform) + primePlatformSpecificHookFor(candidate, version, lcPlatform) } And(~'^the candidate "([^"]*)" version "([^"]*)" is not available for download$') { String candidate, String version -> @@ -57,14 +53,14 @@ And(~/^the candidate "(.*)" version "(.*)" is available for download on "(.*)" w 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 os, String architecture -> +And(~/^a post-installation hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns successfully$/) { String candidate, String version, String os, String architecture -> String lcPlatform = UnixUtils.inferPlatform(os, architecture) - primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookSuccess() : postInstallationHookSuccess()) + primeEndpointWithString("/hooks/post/${candidate}/${version}/${lcPlatform}", postInstallationHookSuccess()) } -And(~/^a "([^"]*)" install hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns a failure$/) { String phase, String candidate, String version, String os, String architecture -> +And(~/^a post-installation hook is served for "([^"]*)" "([^"]*)" on "([^"]*)" with architecture "([^"]*)" that returns a failure$/) { String candidate, String version, String os, String architecture -> String lcPlatform = UnixUtils.inferPlatform(os, architecture) - primeEndpointWithString("/hooks/${phase}/${candidate}/${version}/${lcPlatform}", phase == "pre" ? preInstallationHookFailure() : postInstallationHookFailure()) + primeEndpointWithString("/hooks/post/${candidate}/${version}/${lcPlatform}", postInstallationHookFailure()) } And(~/^the candidate "(.*?)" version "(.*?)" is not available for download on "(.*?)"$/) { String candidate, String version, String os -> diff --git a/src/test/groovy/sdkman/stubs/HookResponses.groovy b/src/test/groovy/sdkman/stubs/HookResponses.groovy index 922cc21fb..8757a564b 100644 --- a/src/test/groovy/sdkman/stubs/HookResponses.groovy +++ b/src/test/groovy/sdkman/stubs/HookResponses.groovy @@ -1,27 +1,7 @@ package sdkman.stubs class HookResponses { - - static preInstallationHookSuccess() { - '''\ -#!/usr/bin/env bash -function __sdkman_pre_installation_hook { - echo "Pre-installation hook success" - return 0 -} -''' - } - - static preInstallationHookFailure() { - '''\ -#!/usr/bin/env bash -function __sdkman_pre_installation_hook { - echo "Pre-installation hook failure" - return 1 -} -''' - } - + static postInstallationHookSuccess() { '''\ #!/usr/bin/env bash diff --git a/src/test/groovy/sdkman/stubs/UnameStub.groovy b/src/test/groovy/sdkman/stubs/UnameStub.groovy index a13a8a46a..422625fbe 100644 --- a/src/test/groovy/sdkman/stubs/UnameStub.groovy +++ b/src/test/groovy/sdkman/stubs/UnameStub.groovy @@ -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() diff --git a/src/test/groovy/sdkman/stubs/WebServiceStub.groovy b/src/test/groovy/sdkman/stubs/WebServiceStub.groovy index 62587aa2f..9a7656009 100644 --- a/src/test/groovy/sdkman/stubs/WebServiceStub.groovy +++ b/src/test/groovy/sdkman/stubs/WebServiceStub.groovy @@ -12,17 +12,17 @@ class WebServiceStub { .withBody(body))) } - static primeUniversalHookFor(String phase, String candidate, String version, String platform) { - primeHookFor(phase, candidate, version, platform, true) + static primeUniversalHookFor(String candidate, String version, String platform) { + primeHookFor(candidate, version, platform, true) } - static primePlatformSpecificHookFor(String phase, String candidate, String version, String platform) { - primeHookFor(phase, candidate, version, platform, false) + static primePlatformSpecificHookFor(String candidate, String version, String platform) { + primeHookFor(candidate, version, platform, false) } - private static primeHookFor(String phase, String candidate, String version, String platform, boolean universal = true) { - def hookFile = "hooks/${phase}_hook_${candidate}_${version}_${universal ? 'universal' : platform}.sh" - stubFor(get(urlEqualTo("/hooks/$phase/$candidate/$version/$platform")).willReturn( + private static primeHookFor(String candidate, String version, String platform, boolean universal = true) { + def hookFile = "hooks/post_hook_${candidate}_${version}_${universal ? 'universal' : platform}.sh" + stubFor(get(urlEqualTo("/hooks/post/$candidate/$version/$platform")).willReturn( aResponse() .withStatus(200) .withHeader("Content-Type", "text/plain") diff --git a/src/test/groovy/sdkman/support/UnixUtils.groovy b/src/test/groovy/sdkman/support/UnixUtils.groovy index 84da33a7b..77547626a 100644 --- a/src/test/groovy/sdkman/support/UnixUtils.groovy +++ b/src/test/groovy/sdkman/support/UnixUtils.groovy @@ -3,17 +3,28 @@ package sdkman.support class UnixUtils { private static platforms = [ - "Linux": [ - "amd64": "LinuxX64" - ], - "Mac OS X": [ - "x86_64": "DarwinX64", + "Linux" : [ + "x86_64": "linuxx64", + "aarch64": "linuxarm64", + + ], + "Darwin": [ + "x86_64": "darwinx64", + "arm64": "darwinarm64", ] ] - + + static execute(String command) { + command.execute().text.trim() + } + + static osName() { execute("uname -s") } + + static osArch() { execute("uname -m") } + static inferPlatform( - osName = System.getProperty("os.name"), - architecture = System.getProperty("os.arch")) { - (platforms[osName][architecture] ?: osName).toLowerCase() + String osName = osName(), + String architecture = osArch()) { + platforms[osName][architecture] ?: osName.toLowerCase() } } diff --git a/src/test/resources/__files/hooks/pre_hook_java_8.0.101_linuxx64.sh b/src/test/resources/__files/hooks/pre_hook_java_8.0.101_linuxx64.sh deleted file mode 100644 index 87139bd86..000000000 --- a/src/test/resources/__files/hooks/pre_hook_java_8.0.101_linuxx64.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# passthrough with zero return code -function __sdkman_pre_installation_hook() { - echo "PRE: passthrough returning zero return code" - return 0 -} diff --git a/src/test/resources/__files/hooks/pre_hook_java_8.0.111_linuxx64.sh b/src/test/resources/__files/hooks/pre_hook_java_8.0.111_linuxx64.sh deleted file mode 100644 index ee8cb7f64..000000000 --- a/src/test/resources/__files/hooks/pre_hook_java_8.0.111_linuxx64.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -# passthrough returns zero return code -function __sdkman_pre_installation_hook() { - echo "PRE: returns with zero return code" - return 0 -} diff --git a/src/test/resources/features/broadcast.feature b/src/test/resources/features/broadcast.feature deleted file mode 100644 index 5d603e979..000000000 --- a/src/test/resources/features/broadcast.feature +++ /dev/null @@ -1,36 +0,0 @@ -Feature: Broadcast - - Background: - Given the internet is reachable - And an initialised environment - And the system is bootstrapped - - Scenario: A command is issued with no prior Broadcast received - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "sdk version" - Then I see "This is a LIVE Broadcast!" - - Scenario: A command is issued where the prior Broadcast was different to the Live one - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "sdk version" - Then I see "This is a LIVE Broadcast!" - - Scenario: A command is issued where the prior Broadcast was the same as the Live one - Given a prior Broadcast "This is a LIVE Broadcast!" with id "12345" was issued - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "sdk version" - Then I do not see "This is a LIVE Broadcast!" - - Scenario: A Broadcast command recalls a prior Broadcast - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And a new Broadcast "This is an OLD Broadcast!" with id "12344" is available - When I enter "sdk broadcast" - Then I see "This is an OLD Broadcast!" - - Scenario: A Broadcast command is issued with no prior Broadcast received - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - When I enter "sdk broadcast" - Then I see "This is a LIVE Broadcast!" diff --git a/src/test/resources/features/checksum_verification.feature b/src/test/resources/features/checksum_verification.feature index bd6759616..03d3b8986 100644 --- a/src/test/resources/features/checksum_verification.feature +++ b/src/test/resources/features/checksum_verification.feature @@ -32,42 +32,6 @@ Feature: Verify checksums And the response headers file is created for candidate "grails" and version "1.3.9" And the exit code is 0 - Scenario: Install an already downloaded Candidate with a valid MD5 checksum and no local headers file - Given the system is bootstrapped - And the candidate "grails" version "1.3.9" is available for download - And the archive "grails-1.3.9.zip" has been cached - When I enter "sdk install grails 1.3.9" - Then I see "Found a previously downloaded grails 1.3.9 archive. Not downloading it again..." - And I see "Done installing!" - And I see "Skipping checksum for cached artifact" - And I do not see "Downloading: grails 1.3.9" - And the candidate "grails" version "1.3.9" is installed - And the exit code is 0 - - Scenario: Install an already downloaded Candidate with a valid MD5 checksum - Given the system is bootstrapped - And the candidate "grails" version "1.3.9" is available for download - And the archive "grails-1.3.9.zip" has been cached - And a headers file "grails-1.3.9.headers" in metadata directory with checksum "1e87a7d982a2f41da96fdec289908552" using algorithm "MD5" - When I enter "sdk install grails 1.3.9" - Then I see "Found a previously downloaded grails 1.3.9 archive. Not downloading it again..." - And I see "Done installing!" - And I do not see "Downloading: grails 1.3.9" - And the candidate "grails" version "1.3.9" is installed - And the exit code is 0 - - Scenario: Install an already downloaded Candidate with a valid SHA1 checksum - Given the system is bootstrapped - And the candidate "grails" version "1.3.9" is available for download - And the archive "grails-1.3.9.zip" has been cached - And a headers file "grails-1.3.9.headers" in metadata directory with checksum "c68e386a6deec9fc4c1e18df21f92739ba2ab36e" using algorithm "SHA1" - When I enter "sdk install grails 1.3.9" - Then I see "Found a previously downloaded grails 1.3.9 archive. Not downloading it again..." - And I see "Done installing!" - And I do not see "Downloading: grails 1.3.9" - And the candidate "grails" version "1.3.9" is installed - And the exit code is 0 - Scenario: Do not fail if an unknown algorithm is used Given the system is bootstrapped And the candidate "grails" version "1.3.9" is available for download with checksum "abc-checksum-00000" using algorithm "ABC" @@ -97,7 +61,8 @@ Feature: Verify checksums And the candidate "grails" version "1.3.9" is installed And the response headers file is created for candidate "grails" and version "1.3.9" And the exit code is 0 - + + @manual Scenario: Abort installation after download of a binary with invalid SHA checksum Given the system is bootstrapped And the candidate "grails" version "1.3.9" is available for download with checksum "c68e386a6deec9fc4c1e18df21f927000000000e" using algorithm "SHA-256" diff --git a/src/test/resources/features/flush.feature b/src/test/resources/features/flush.feature index 10aa355dc..096b3f5dc 100644 --- a/src/test/resources/features/flush.feature +++ b/src/test/resources/features/flush.feature @@ -5,40 +5,21 @@ Feature: Flush And an initialised environment And the system is bootstrapped - Scenario: Clear out the cached archives, the temporary storage and metadata - Given the archive "grails-1.3.9.zip" has been cached + Scenario: Clear out the temporary storage and metadata And the file "res-1.2.0.zip" in temporary storage And a headers file "grails-1.3.9.headers" in metadata directory with checksum "c68e386a6deec9fc4c1e18df21f92739ba2ab36e" using algorithm "SHA1" When I enter "sdk flush" - Then no archives are cached And no "res-1.2.0.zip" file is present in temporary storage And no metadata is cached And I see "1 archive(s) flushed" And I see "1 archive(s) flushed" - Scenario: Clean up the current Broadcast - Given a prior Broadcast "This is an old broadcast" with id "12344" was issued - When I enter "sdk flush broadcast" - Then no broadcast message can be found - And I see "Broadcast has been flushed." - - Scenario: Clean up an uninitialised Broadcast - Given the broadcast has been flushed - When I enter "sdk flush broadcast" - Then I see "No prior broadcast found so not flushed." - Scenario: Clean up the last known Remote Version Given a prior version "5.0.0" was detected When I enter "sdk flush version" Then no version file can be found And I see "Version file has been flushed." - Scenario: Clear out the cached Archives - Given the archive "grails-1.3.9.zip" has been cached - When I enter "sdk flush archives" - Then no archives are cached - And I see "1 archive(s) flushed" - Scenario: Clear out the temporary storage Given the file "res-1.2.0.zip" in temporary storage When I enter "sdk flush temp" diff --git a/src/test/resources/features/hooks.feature b/src/test/resources/features/hooks.feature new file mode 100644 index 000000000..fd47f9bd4 --- /dev/null +++ b/src/test/resources/features/hooks.feature @@ -0,0 +1,25 @@ +Feature: Hooks + + We can safely remove this feature when `.tar.gz` and `.zip` are supported directly by the backend. + + Background: + Given the internet is reachable + And an initialised environment + + Scenario: Post-installation Hook returns successfully + And an "x86_64" machine with "Linux" installed + And the system is bootstrapped + And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" + And a post-installation hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns successfully + When I enter "sdk install grails 2.1.0" + And I see "Post-installation hook success" + And the exit code is 0 + + Scenario: Post-install Hook returns a non-zero code + And an "x86_64" machine with "Linux" installed + And the system is bootstrapped + And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "x86_64" + And a post-installation hook is served for "grails" "2.1.0" on "Linux" with architecture "x86_64" that returns a failure + When I enter "sdk install grails 2.1.0" + Then I see "Post-installation hook failure" + And the exit code is 1 diff --git a/src/test/resources/features/idempotent_self_update.feature b/src/test/resources/features/idempotent_self_update.feature deleted file mode 100644 index d5373f5cc..000000000 --- a/src/test/resources/features/idempotent_self_update.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Idempotent Self Update - - Background: - Given the internet is reachable - And an initialised environment - And the system is bootstrapped - And an available selfupdate - - Scenario: Attempt Self Update on an up to date system - When I enter "sdk selfupdate" - Then I see "No update available at this time." - - Scenario: Force Self Update on an up to date system - When I enter "sdk selfupdate force" - Then I see "Successfully upgraded SDKMAN." diff --git a/src/test/resources/features/install_candidate.feature b/src/test/resources/features/install_candidate.feature index d41a0be2b..2b855edd4 100644 --- a/src/test/resources/features/install_candidate.feature +++ b/src/test/resources/features/install_candidate.feature @@ -82,17 +82,6 @@ Feature: Install Candidate And the candidate "grails" version "1.3.9" should be the default And the exit code is 0 - Scenario: Install an already downloaded Candidate - Given the system is bootstrapped - And the candidate "grails" version "1.3.9" is available for download - And the archive "grails-1.3.9.zip" has been cached - When I enter "sdk install grails 1.3.9" - Then I see "Found a previously downloaded grails 1.3.9 archive. Not downloading it again..." - And I see "Done installing!" - And I do not see "Downloading: grails 1.3.9" - And the candidate "grails" version "1.3.9" is installed - And the exit code is 0 - # revisit to redownload automatically Scenario: Abort installation on download of a corrupt Candidate archive diff --git a/src/test/resources/features/java_installation.feature b/src/test/resources/features/java_installation.feature index 16e406e07..dd7bdc4fe 100644 --- a/src/test/resources/features/java_installation.feature +++ b/src/test/resources/features/java_installation.feature @@ -4,44 +4,44 @@ Feature: Java Multi Platform Binary Distribution This feature uses real hooks found in the resources folder under /hooks. The following hooks are available: - 8.0.111: pre- and post-hooks prepared for successful installation - 8.0.101: pre-hook succeeds but post-hook aborts with non-zero return code + 8.0.111: post-hook prepared for successful installation + 8.0.101: post-hook aborts with non-zero return code Background: Given the internet is reachable And an initialised environment Scenario: Platform is supported and a specific version of compatible binary is installed - Given an "amd64" machine with "Linux" installed + Given an "x86_64" machine with "Linux" installed And the system is bootstrapped - And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "amd64" - And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "amd64" + And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "x86_64" + And the appropriate multi-platform hook is available for "java" version "8.0.111" on "Linux" with architecture "x86_64" When I enter "sdk install java 8.0.111" And I see "Done installing!" And the candidate "java" version "8.0.111" is installed Scenario: Platform is supported and a default version of compatible binary is installed - Given an "amd64" machine with "Linux" installed + Given an "x86_64" 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 available for download on "Linux" with architecture "amd64" - And the appropriate multi-platform hooks are available for "java" version "8.0.111" on "Linux" with architecture "amd64" + And the candidate "java" version "8.0.111" is available for download on "Linux" with architecture "x86_64" + And the appropriate multi-platform hook is available for "java" version "8.0.111" on "Linux" with architecture "x86_64" When I enter "sdk install java" And I see "Done installing!" And the candidate "java" version "8.0.111" is installed Scenario: Platform is supported but download fails - Given an "amd64" machine with "Linux" installed + Given an "x86_64" machine with "Linux" installed And the system is bootstrapped - And the candidate "java" version "8.0.101" is available for download on "Linux" with architecture "amd64" - And the appropriate multi-platform hooks are available for "java" version "8.0.101" on "Linux" with architecture "amd64" + And the candidate "java" version "8.0.101" is available for download on "Linux" with architecture "x86_64" + And the appropriate multi-platform hook is available for "java" version "8.0.101" on "Linux" with architecture "x86_64" When I enter "sdk install java 8.0.101" And I see "Download has failed, aborting!" And the candidate "java" version "8.0.101" is not installed 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 "Linux" installed + And an "x86_64" machine with "Linux" installed And the system is bootstrapped And the candidate "java" version "8.0.111" is not available for download on "Linux" When I enter "sdk install java 8.0.111" @@ -54,7 +54,7 @@ Feature: Java Multi Platform Binary Distribution 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 "Linux" installed + And an "x86_64" 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 "Linux" diff --git a/src/test/resources/features/mnemonics.feature b/src/test/resources/features/mnemonics.feature index 3aac8efa0..0f25ca4c4 100644 --- a/src/test/resources/features/mnemonics.feature +++ b/src/test/resources/features/mnemonics.feature @@ -80,16 +80,8 @@ Feature: Mnemonics Then I see "Default groovy version set to 2.0.5" And the candidate "groovy" version "2.0.5" should be the default - Scenario: Shortcut for a Broadcast command issued - Given no prior Broadcast was received - And a new Broadcast "This is a LIVE Broadcast!" with id "12345" is available - And the system is bootstrapped - When I enter "sdk b" - Then I see "This is a LIVE Broadcast!" - 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" diff --git a/src/test/resources/features/offline_mode.feature b/src/test/resources/features/offline_mode.feature index eab3b4fd7..064f96797 100644 --- a/src/test/resources/features/offline_mode.feature +++ b/src/test/resources/features/offline_mode.feature @@ -48,16 +48,6 @@ Feature: Offline Mode Then I see "INTERNET NOT REACHABLE!" And I see "Stop! grails 2.1.0 is not available while offline." - # broadcast - - Scenario: Recall a broadcast while in Offline Mode - Given offline mode is enabled with reachable internet - And an initialised environment - And the system is bootstrapped - When a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And I enter "sdk broadcast" - Then I see "This is an OLD Broadcast!" - # sdk version Scenario: Determine the sdkman version while in Offline Mode diff --git a/src/test/resources/features/pre_and_post_installation_hooks.feature b/src/test/resources/features/pre_and_post_installation_hooks.feature deleted file mode 100644 index d6667db53..000000000 --- a/src/test/resources/features/pre_and_post_installation_hooks.feature +++ /dev/null @@ -1,37 +0,0 @@ -Feature: Hooks - - We can safely remove this feature when `.tar.gz` and `.zip` are supported directly by the backend. - - Background: - Given the internet is reachable - And an initialised environment - - Scenario: Pre- and Post-installation Hooks return successfully - And an "amd64" machine with "Linux" installed - And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "amd64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns successfully - And a "post" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns successfully - When I enter "sdk install grails 2.1.0" - Then I see "Pre-installation hook success" - And I see "Post-installation hook success" - And the exit code is 0 - - Scenario: Pre-installation Hook returns a non-zero code - And an "amd64" machine with "Linux" installed - And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "amd64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns a failure - When I enter "sdk install grails 2.1.0" - Then I see "Pre-installation hook failure" - And the exit code is 1 - - Scenario: Post-install Hook returns a non-zero code - And an "amd64" machine with "Linux" installed - And the system is bootstrapped - And the candidate "grails" version "2.1.0" is available for download on "Linux" with architecture "amd64" - And a "pre" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns successfully - And a "post" install hook is served for "grails" "2.1.0" on "Linux" with architecture "amd64" that returns a failure - When I enter "sdk install grails 2.1.0" - Then I see "Post-installation hook failure" - And the exit code is 1 diff --git a/src/test/resources/features/self_update.feature b/src/test/resources/features/self_update.feature index 2baf8252a..1d0ef7bc2 100644 --- a/src/test/resources/features/self_update.feature +++ b/src/test/resources/features/self_update.feature @@ -1,90 +1,34 @@ -@manual Feature: Self Update Background: Given the internet is reachable - - Scenario: Force a Selfupdate - Given an initialised environment + And the sdkman scripts version is "5.0.0" + And the sdkman native version is "0.0.1" + And an initialised environment And the system is bootstrapped - When I enter "sdk selfupdate force" - Then I do not see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Updating SDKMAN..." - And I see "Successfully upgraded SDKMAN." + And an available selfupdate endpoint - Scenario: Selfupdate when out of date - Given an outdated initialised environment - And the system is bootstrapped + Scenario: Attempt Self Update with out dated scripts components + Given the sdkman script version "6.0.0" is available for download + And the sdkman native version "0.0.1" is available for download When I enter "sdk selfupdate" - Then I do not see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Updating SDKMAN..." - And I see "Successfully upgraded SDKMAN." - - Scenario: Agree to a suggested Selfupdate - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk help" and answer "Y" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Successfully upgraded SDKMAN." - And I do not see "Not upgrading today..." - - Scenario: Do not agree to a suggested Selfupdate - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk help" and answer "N" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I do not see "Successfully upgraded SDKMAN." - - Scenario: Automatically Selfupdate - Given an outdated initialised environment - And the configuration file has been primed with "sdkman_auto_answer=true" - And the system is bootstrapped - When I enter "sdk help" - Then I see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading today..." - And I see "Successfully upgraded SDKMAN." + Then I see "Successfully upgraded SDKMAN." - Scenario: Do not automatically Selfupdate - Given an outdated initialised environment - And the configuration file has been primed with "sdkman_auto_answer=false" - And the system is bootstrapped - When I enter "sdk help" and answer "n" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I do not see "Successfully upgraded SDKMAN." - - Scenario: Do not check and prompt for update - Given an outdated initialised environment - And the configuration file has been primed with "sdkman_selfupdate_enable=false" - And the system is bootstrapped - When I enter "sdk help" - Then I do not see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - - Scenario: Bother the user with Upgrade message once a day - Given an outdated initialised environment - And the system is bootstrapped - When I enter "sdk help" and answer "N" - Then I see "A new version of SDKMAN is available..." - And I see "Would you like to upgrade now? (Y/n)" - And I see "Not upgrading today..." - And I enter "sdk help" - Then I do not see "A new version of SDKMAN is available..." - And I do not see "Would you like to upgrade now? (Y/n)" - And I do not see "Not upgrading now..." - And I do not see "Successfully upgraded SDKMAN." + Scenario: Attempt Self Update with out dated native components + Given the sdkman script version "5.0.0" is available for download + And the sdkman native version "0.0.2" is available for download + When I enter "sdk selfupdate" + Then I see "Successfully upgraded SDKMAN." - Scenario: Selfupdate when not out of date - Given an initialised environment - And the system is bootstrapped + Scenario: Attempt Self Update on an up to date system + Given the sdkman script version "5.0.0" is available for download + And the sdkman native version "0.0.1" is available for download When I enter "sdk selfupdate" Then I see "No update available at this time." + + Scenario: Force Self Update on an up to date system + Given the sdkman script version "5.0.0" is available for download + And the sdkman native version "0.0.1" is available for download + When I enter "sdk selfupdate force" + Then I see "Successfully upgraded SDKMAN." + \ No newline at end of file diff --git a/src/test/resources/features/service_unavailable.feature b/src/test/resources/features/service_unavailable.feature index f78810f90..98289803f 100644 --- a/src/test/resources/features/service_unavailable.feature +++ b/src/test/resources/features/service_unavailable.feature @@ -112,14 +112,6 @@ Feature: Service Unavailable When I enter "sdk version" Then I see the current sdkman version - # broadcast command - - Scenario: Recall a broadcast while Offline - Given a prior Broadcast "This is an OLD Broadcast!" with id "12344" was issued - And the system is bootstrapped - When I enter "sdk broadcast" - Then I see "This is an OLD Broadcast!" - # help command Scenario: Request help while Offline diff --git a/src/test/resources/features/version.feature b/src/test/resources/features/version.feature index 00e6617fb..1b2529ba9 100644 --- a/src/test/resources/features/version.feature +++ b/src/test/resources/features/version.feature @@ -2,7 +2,7 @@ Feature: Version Scenario: Show the current version of sdkman Given the internet is reachable - And the sdkman version is "3.2.1" + And the sdkman scripts version is "3.2.1" And an initialised environment And the system is bootstrapped When I enter "sdk version"