From a770be4c570a0d611540bcd8e0d3ca0300f2ec54 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Wed, 6 Sep 2023 16:39:49 -0300 Subject: [PATCH 01/21] feat: unset all enviroment variavles it is a feature create by recommendation of issue 1619 --- .../command-export-shell-version.bash | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 92ace8abe..ac77febbb 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -2,19 +2,50 @@ # shellcheck source=lib/functions/versions.bash . "$(dirname "$(dirname "$0")")/lib/functions/versions.bash" +unset_all_fish(){ + printf "for var in (env | awk -F= '/^ASDF_[A-Za-z0-9_]+_VERSION=/ {print \$1}')\n" + printf " echo Removing Env: \$var\n" + printf " set -e \$var\n" + printf "end\n" +} +unset_all(){ + printf "for var in \$(env | awk -F= '/^ASDF_[A-Za-z0-9_]+_VERSION=/ {print \$1}'); do\n" + printf " echo Removing Env: " + printf " \$var\n" + printf " unset \$var\n" + printf "done\n" +} + # Output from this command must be executable shell code -shell_command() { +shell_command() { local asdf_shell="$1" shift - - if [ "$#" -lt "2" ]; then - printf "Usage: asdf shell {|--unset}\n" >&2 + + if [ "$#" -lt "2" ] && [ "$1" != "--unset-all" ]; then + printf "Usage: asdf shell { {|--unset}|--unset-all}\n" >&2 printf "false\n" exit 1 fi local plugin=$1 local version=$2 + + if [ "$plugin" = "--unset-all" ] ; then + case "$asdf_shell" in + fish) + unset_all_fish + ;; + elvish) + # TODO + printf 'print It will be implemented soon' + ;; + *) + unset_all + ;; + esac + + exit 0 + fi local upcase_name upcase_name=$(tr '[:lower:]-' '[:upper:]_' <<<"$plugin") @@ -69,3 +100,6 @@ shell_command() { } shell_command "$@" + + + From 7bb968a3fb66093e985087830d5c550579f8a6ed Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Wed, 6 Sep 2023 16:41:20 -0300 Subject: [PATCH 02/21] uupdate: removed whitespaces --- lib/commands/command-export-shell-version.bash | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index ac77febbb..9489a1819 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -100,6 +100,3 @@ shell_command() { } shell_command "$@" - - - From f840b8b65b1cd9cfe03d110f9c01409f2ab2d57e Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Sun, 10 Sep 2023 22:28:11 -0300 Subject: [PATCH 03/21] update: pr adjustments line indetation, elvish custom print and add parameter -v in unset_all --- lib/commands/command-export-shell-version.bash | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 9489a1819..7b1f12101 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -9,18 +9,18 @@ unset_all_fish(){ printf "end\n" } unset_all(){ - printf "for var in \$(env | awk -F= '/^ASDF_[A-Za-z0-9_]+_VERSION=/ {print \$1}'); do\n" - printf " echo Removing Env: " - printf " \$var\n" - printf " unset \$var\n" - printf "done\n" + printf "for var in \$(env | awk -F= '/^ASDF_[A-Za-z0-9_]+_VERSION=/ {print \$1}'); do\n" + printf " echo Removing Env: " + printf " \$var\n" + printf " unset -v \$var\n" + printf "done\n" } # Output from this command must be executable shell code shell_command() { local asdf_shell="$1" shift - + if [ "$#" -lt "2" ] && [ "$1" != "--unset-all" ]; then printf "Usage: asdf shell { {|--unset}|--unset-all}\n" >&2 printf "false\n" @@ -37,7 +37,7 @@ shell_command() { ;; elvish) # TODO - printf 'print It will be implemented soon' + printf "asdf: Flag '--unset-all' not implemented for Elvish shell" >&2 ;; *) unset_all From 98f217641e3ac0132c2edd9aa3ff637d5908495a Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Sun, 10 Sep 2023 22:32:04 -0300 Subject: [PATCH 04/21] update: lint fix --- .../command-export-shell-version.bash | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 7b1f12101..8afd1f4da 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -2,25 +2,25 @@ # shellcheck source=lib/functions/versions.bash . "$(dirname "$(dirname "$0")")/lib/functions/versions.bash" -unset_all_fish(){ +unset_all_fish() { printf "for var in (env | awk -F= '/^ASDF_[A-Za-z0-9_]+_VERSION=/ {print \$1}')\n" printf " echo Removing Env: \$var\n" printf " set -e \$var\n" printf "end\n" } -unset_all(){ +unset_all() { printf "for var in \$(env | awk -F= '/^ASDF_[A-Za-z0-9_]+_VERSION=/ {print \$1}'); do\n" - printf " echo Removing Env: " + printf " echo Removing Env: " printf " \$var\n" printf " unset -v \$var\n" printf "done\n" } # Output from this command must be executable shell code -shell_command() { +shell_command() { local asdf_shell="$1" shift - + if [ "$#" -lt "2" ] && [ "$1" != "--unset-all" ]; then printf "Usage: asdf shell { {|--unset}|--unset-all}\n" >&2 printf "false\n" @@ -29,21 +29,21 @@ shell_command() { local plugin=$1 local version=$2 - - if [ "$plugin" = "--unset-all" ] ; then - case "$asdf_shell" in + + if [ "$plugin" = "--unset-all" ]; then + case "$asdf_shell" in fish) unset_all_fish ;; elvish) # TODO printf "asdf: Flag '--unset-all' not implemented for Elvish shell" >&2 - ;; + ;; *) - unset_all + unset_all ;; esac - + exit 0 fi From d55b53aef627e59d6bb6ce9547d83b3943c46a5e Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Tue, 12 Sep 2023 14:51:49 -0300 Subject: [PATCH 05/21] update: unset_all is now on the top --- .../command-export-shell-version.bash | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 8afd1f4da..f97f52ed9 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -20,17 +20,8 @@ unset_all() { shell_command() { local asdf_shell="$1" shift - - if [ "$#" -lt "2" ] && [ "$1" != "--unset-all" ]; then - printf "Usage: asdf shell { {|--unset}|--unset-all}\n" >&2 - printf "false\n" - exit 1 - fi - - local plugin=$1 - local version=$2 - - if [ "$plugin" = "--unset-all" ]; then + + if [ "$1" = '--unset-all' ]; then case "$asdf_shell" in fish) unset_all_fish @@ -43,10 +34,18 @@ shell_command() { unset_all ;; esac - exit 0 fi + + + if [ "$#" -lt "2" ]; then + printf "Usage: asdf shell { {|--unset}|--unset-all}\n" >&2 + printf "false\n" + exit 1 + fi + local plugin=$1 + local version=$2 local upcase_name upcase_name=$(tr '[:lower:]-' '[:upper:]_' <<<"$plugin") local version_env_var="ASDF_${upcase_name}_VERSION" From 5acb20510d18425d8f4e20e53ee66428a2e9bba8 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Tue, 12 Sep 2023 14:56:48 -0300 Subject: [PATCH 06/21] fix: lint update --- lib/commands/command-export-shell-version.bash | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index f97f52ed9..c1107b4a4 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -20,7 +20,7 @@ unset_all() { shell_command() { local asdf_shell="$1" shift - + if [ "$1" = '--unset-all' ]; then case "$asdf_shell" in fish) @@ -36,7 +36,6 @@ shell_command() { esac exit 0 fi - if [ "$#" -lt "2" ]; then printf "Usage: asdf shell { {|--unset}|--unset-all}\n" >&2 From 3bcf682ef1627f3921e23e4b5a534fa58d28f39c Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Tue, 19 Sep 2023 15:12:37 -0300 Subject: [PATCH 07/21] tests: created tests i expect it works =] - i had to copy asdf.sh to source it --- test/shell_command.bats | 28 ++++++++++++++++++++++++++++ test/test_helpers.bash | 9 +++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/shell_command.bats diff --git a/test/shell_command.bats b/test/shell_command.bats new file mode 100644 index 000000000..fc057f976 --- /dev/null +++ b/test/shell_command.bats @@ -0,0 +1,28 @@ + + +load test_helpers + +setup() { + setup_asdf_dir + install_dummy_plugin + install_dummy_version "1.1.0" + install_dummy_version "1.2.0" + install_dummy_version "nightly-2000-01-01" +} +teardown() { + clean_asdf_dir +} +@test "shell_command with 'latest' version" { + run asdf shell dummy 1.1.0 + [ "$status" -eq 0 ] +} + + +@test "asdf shell --unset-all removes all ASDF_{PLUGIN}_VERSION" { + # mock data + run export ASDF_DUMMY_VERSION="1.1.0" + run asdf shell --unset-all + [ "$status" -eq 0 ] + +} + diff --git a/test/test_helpers.bash b/test/test_helpers.bash index 103da76cd..acfac6ad1 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -20,6 +20,15 @@ setup_asdf_dir() { mkdir -p "$ASDF_DIR/tmp" ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin" + # it is necessary so execute shell command + cp -r .. "$ASDF_DIR" + + if source "$ASDF_DIR/asdf.sh"; then + echo "Sourced asdf.sh successfully." + else + echo "Error: Unable to source asdf.sh. Please report this fail." + exit 1 + fi # shellcheck disable=SC2031 PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH" } From ab330e985b0e7378ecf3d6de71c1068b0b3d245d Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Tue, 19 Sep 2023 15:22:21 -0300 Subject: [PATCH 08/21] update: lint --- test/shell_command.bats | 4 ---- test/test_helpers.bash | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/test/shell_command.bats b/test/shell_command.bats index fc057f976..c3cf56756 100644 --- a/test/shell_command.bats +++ b/test/shell_command.bats @@ -1,5 +1,3 @@ - - load test_helpers setup() { @@ -17,7 +15,6 @@ teardown() { [ "$status" -eq 0 ] } - @test "asdf shell --unset-all removes all ASDF_{PLUGIN}_VERSION" { # mock data run export ASDF_DUMMY_VERSION="1.1.0" @@ -25,4 +22,3 @@ teardown() { [ "$status" -eq 0 ] } - diff --git a/test/test_helpers.bash b/test/test_helpers.bash index acfac6ad1..b7cdc97a3 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -20,7 +20,7 @@ setup_asdf_dir() { mkdir -p "$ASDF_DIR/tmp" ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin" - # it is necessary so execute shell command + # it is necessary so execute shell command cp -r .. "$ASDF_DIR" if source "$ASDF_DIR/asdf.sh"; then From fb3245ffe822231098406ee08c5b444ca72bc7aa Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Tue, 19 Sep 2023 15:34:17 -0300 Subject: [PATCH 09/21] ls ASDF DIR --- test/test_helpers.bash | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_helpers.bash b/test/test_helpers.bash index b7cdc97a3..62421aa75 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -29,6 +29,8 @@ setup_asdf_dir() { echo "Error: Unable to source asdf.sh. Please report this fail." exit 1 fi + + ls -a "$ASDF_DIR" # shellcheck disable=SC2031 PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH" } From 4080b8e6039b8ead8557df6f8dce9d3e221040d0 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Wed, 20 Sep 2023 11:42:21 -0300 Subject: [PATCH 10/21] update: check output of the tests --- test/shell_command.bats | 5 ++++- test/test_helpers.bash | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/test/shell_command.bats b/test/shell_command.bats index c3cf56756..e7e5a9286 100644 --- a/test/shell_command.bats +++ b/test/shell_command.bats @@ -12,6 +12,8 @@ teardown() { } @test "shell_command with 'latest' version" { run asdf shell dummy 1.1.0 + echo "Actual Output: $output" + echo "Actual Exit Status: $status" [ "$status" -eq 0 ] } @@ -19,6 +21,7 @@ teardown() { # mock data run export ASDF_DUMMY_VERSION="1.1.0" run asdf shell --unset-all + echo "Actual Output: $output" + echo "Actual Exit Status: $status" [ "$status" -eq 0 ] - } diff --git a/test/test_helpers.bash b/test/test_helpers.bash index 62421aa75..a6bbb2e44 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -21,14 +21,14 @@ setup_asdf_dir() { ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin" # it is necessary so execute shell command - cp -r .. "$ASDF_DIR" - - if source "$ASDF_DIR/asdf.sh"; then - echo "Sourced asdf.sh successfully." - else - echo "Error: Unable to source asdf.sh. Please report this fail." - exit 1 - fi + # cp -r .. "$ASDF_DIR" + + # if source "$ASDF_DIR/asdf.sh"; then + # echo "Sourced asdf.sh successfully." + # else + # echo "Error: Unable to source asdf.sh. Please report this fail." + # exit 1 + # fi ls -a "$ASDF_DIR" # shellcheck disable=SC2031 From e540d19532b8a2d7689c9c84a26b999c659f8e00 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 15:45:04 -0300 Subject: [PATCH 11/21] test: new test with ruby --- test/shell_command.bats | 5 ++++- test/test_helpers.bash | 18 +++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/test/shell_command.bats b/test/shell_command.bats index e7e5a9286..5045b2651 100644 --- a/test/shell_command.bats +++ b/test/shell_command.bats @@ -10,8 +10,11 @@ setup() { teardown() { clean_asdf_dir } + @test "shell_command with 'latest' version" { - run asdf shell dummy 1.1.0 + run asdf plugin add ruby + run asdf install ruby 3.2.0 + run asdf shell ruby 3.2.0 echo "Actual Output: $output" echo "Actual Exit Status: $status" [ "$status" -eq 0 ] diff --git a/test/test_helpers.bash b/test/test_helpers.bash index a6bbb2e44..a2173ac8c 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -20,15 +20,15 @@ setup_asdf_dir() { mkdir -p "$ASDF_DIR/tmp" ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin" - # it is necessary so execute shell command - # cp -r .. "$ASDF_DIR" - - # if source "$ASDF_DIR/asdf.sh"; then - # echo "Sourced asdf.sh successfully." - # else - # echo "Error: Unable to source asdf.sh. Please report this fail." - # exit 1 - # fi + # it is necessary to execute shell command + cp -r .. "$ASDF_DIR" + + if source "$ASDF_DIR/asdf.sh"; then + echo "Sourced asdf.sh successfully." + else + echo "Error: Unable to source asdf.sh. Please report this fail." + exit 1 + fi ls -a "$ASDF_DIR" # shellcheck disable=SC2031 From d06bfe5b3c24308e7528286a7f1c2d9dc228218b Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 16:30:18 -0300 Subject: [PATCH 12/21] update: doing ls before trying source --- test/test_helpers.bash | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/test_helpers.bash b/test/test_helpers.bash index a2173ac8c..0d219aab7 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -21,16 +21,15 @@ setup_asdf_dir() { ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin" # it is necessary to execute shell command - cp -r .. "$ASDF_DIR" - + cp -r .. "$ASDF_DIR/" + ls -a "$ASDF_DIR" if source "$ASDF_DIR/asdf.sh"; then - echo "Sourced asdf.sh successfully." - else - echo "Error: Unable to source asdf.sh. Please report this fail." - exit 1 + echo "Sourced asdf.sh successfully." + else + echo "Error: Unable to source asdf.sh. Please report this fail." + exit 1 fi - ls -a "$ASDF_DIR" # shellcheck disable=SC2031 PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH" } From e62389ce3dbe0085f0436f870f595eed464ed97c Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 17:05:05 -0300 Subject: [PATCH 13/21] changed copy --- test/test_helpers.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_helpers.bash b/test/test_helpers.bash index 0d219aab7..00a0f6439 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -21,7 +21,7 @@ setup_asdf_dir() { ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin" # it is necessary to execute shell command - cp -r .. "$ASDF_DIR/" + cp -r . "$ASDF_DIR/" ls -a "$ASDF_DIR" if source "$ASDF_DIR/asdf.sh"; then echo "Sourced asdf.sh successfully." From 672d5efb65d1bf6d6de174b856c310e4e0b50439 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 17:14:03 -0300 Subject: [PATCH 14/21] removed ls --- test/test_helpers.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/test/test_helpers.bash b/test/test_helpers.bash index 00a0f6439..5d6a11cc0 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -22,7 +22,6 @@ setup_asdf_dir() { # it is necessary to execute shell command cp -r . "$ASDF_DIR/" - ls -a "$ASDF_DIR" if source "$ASDF_DIR/asdf.sh"; then echo "Sourced asdf.sh successfully." else From 1b3f40dbad501f2a67c6f1cc4050cda4a8da9b74 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 17:32:48 -0300 Subject: [PATCH 15/21] update: create a specific function to source asdf --- test/shell_command.bats | 6 ++---- test/test_helpers.bash | 9 ++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/shell_command.bats b/test/shell_command.bats index 5045b2651..212e0c740 100644 --- a/test/shell_command.bats +++ b/test/shell_command.bats @@ -1,7 +1,7 @@ load test_helpers setup() { - setup_asdf_dir + setup_asdf_dir_wwith_shell install_dummy_plugin install_dummy_version "1.1.0" install_dummy_version "1.2.0" @@ -11,7 +11,7 @@ teardown() { clean_asdf_dir } -@test "shell_command with 'latest' version" { +@test "shell_command with 'specific' version" { run asdf plugin add ruby run asdf install ruby 3.2.0 run asdf shell ruby 3.2.0 @@ -21,8 +21,6 @@ teardown() { } @test "asdf shell --unset-all removes all ASDF_{PLUGIN}_VERSION" { - # mock data - run export ASDF_DUMMY_VERSION="1.1.0" run asdf shell --unset-all echo "Actual Output: $output" echo "Actual Exit Status: $status" diff --git a/test/test_helpers.bash b/test/test_helpers.bash index 5d6a11cc0..2c4168ed4 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -20,6 +20,12 @@ setup_asdf_dir() { mkdir -p "$ASDF_DIR/tmp" ASDF_BIN="$(dirname "$BATS_TEST_DIRNAME")/bin" + # shellcheck disable=SC2031 + PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH" +} + +setup_asdf_dir_wwith_shell() { + setup_asdf_dir # it is necessary to execute shell command cp -r . "$ASDF_DIR/" if source "$ASDF_DIR/asdf.sh"; then @@ -28,9 +34,6 @@ setup_asdf_dir() { echo "Error: Unable to source asdf.sh. Please report this fail." exit 1 fi - - # shellcheck disable=SC2031 - PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH" } install_mock_plugin() { From 07864678acc33d45c362f6ba83e4ce98bd48e5e0 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 17:45:05 -0300 Subject: [PATCH 16/21] i found the function where tests shell remove my older file remove function created about shell in test helpers --- test/shell_command.bats | 28 ---------------------------- test/test_helpers.bash | 14 +------------- test/version_commands.bats | 15 ++++++++++++++- 3 files changed, 15 insertions(+), 42 deletions(-) delete mode 100644 test/shell_command.bats diff --git a/test/shell_command.bats b/test/shell_command.bats deleted file mode 100644 index 212e0c740..000000000 --- a/test/shell_command.bats +++ /dev/null @@ -1,28 +0,0 @@ -load test_helpers - -setup() { - setup_asdf_dir_wwith_shell - install_dummy_plugin - install_dummy_version "1.1.0" - install_dummy_version "1.2.0" - install_dummy_version "nightly-2000-01-01" -} -teardown() { - clean_asdf_dir -} - -@test "shell_command with 'specific' version" { - run asdf plugin add ruby - run asdf install ruby 3.2.0 - run asdf shell ruby 3.2.0 - echo "Actual Output: $output" - echo "Actual Exit Status: $status" - [ "$status" -eq 0 ] -} - -@test "asdf shell --unset-all removes all ASDF_{PLUGIN}_VERSION" { - run asdf shell --unset-all - echo "Actual Output: $output" - echo "Actual Exit Status: $status" - [ "$status" -eq 0 ] -} diff --git a/test/test_helpers.bash b/test/test_helpers.bash index 2c4168ed4..e6407693f 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -24,19 +24,7 @@ setup_asdf_dir() { PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH" } -setup_asdf_dir_wwith_shell() { - setup_asdf_dir - # it is necessary to execute shell command - cp -r . "$ASDF_DIR/" - if source "$ASDF_DIR/asdf.sh"; then - echo "Sourced asdf.sh successfully." - else - echo "Error: Unable to source asdf.sh. Please report this fail." - exit 1 - fi -} - -install_mock_plugin() { +unstall_mock_plugin() { local plugin_name=$1 local location="${2:-$ASDF_DIR}" cp -r "$BATS_TEST_DIRNAME/fixtures/dummy_plugin" "$location/plugins/$plugin_name" diff --git a/test/version_commands.bats b/test/version_commands.bats index 3c9fd0f76..e19d9ee0f 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -335,7 +335,7 @@ teardown() { touch other-dir/.tool-versions ln -s other-dir/.tool-versions .tool-versions run asdf local "dummy" "1.1.0" - run asdf local "dummy" "1.1.0" + run asdf local "dummy" "1.1.0"shell wrapper function with --unset should unset ENV var [ "$status" -eq 0 ] [ -L .tool-versions ] [ "$(cat other-dir/.tool-versions)" = "dummy 1.1.0" ] @@ -380,6 +380,19 @@ teardown() { unset ASDF_DUMMY_VERSION } +@test "shell wrapper function with --unset-all should unset all ENV var" { + . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh" + asdf shell "dummy" "1.1.0" + asdf shell "legacy-dummy" "1.2.0" + [ "$ASDF_DUMMY_VERSION" = "1.1.0" ] + [ "$ASDF_LEGACY_DUMMY_VERSION" = "1.0.0" ] + asdf shell --unset-all + [ -z "$ASDF_DUMMY_VERSION" ] + [ -z "$ASDF_LEGACY_DUMMY_VERSION" ] + unset ASDF_DUMMY_VERSION + unset ASDF_LEGACY_DUMMY_VERSION +} + @test "shell wrapper function should return an error for missing plugins" { . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh" expected="No such plugin: nonexistent From 65a09789d919e2bf72c9c7a916f88c515025c7fb Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 17:51:11 -0300 Subject: [PATCH 17/21] adjusted test_helpers for some reason i changed to 'unstall'' --- test/test_helpers.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_helpers.bash b/test/test_helpers.bash index e6407693f..103da76cd 100644 --- a/test/test_helpers.bash +++ b/test/test_helpers.bash @@ -24,7 +24,7 @@ setup_asdf_dir() { PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH" } -unstall_mock_plugin() { +install_mock_plugin() { local plugin_name=$1 local location="${2:-$ASDF_DIR}" cp -r "$BATS_TEST_DIRNAME/fixtures/dummy_plugin" "$location/plugins/$plugin_name" From d78468a907689da23f1b183b39e1e035c29755a7 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 17:54:12 -0300 Subject: [PATCH 18/21] removed comment in other test --- test/version_commands.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/version_commands.bats b/test/version_commands.bats index e19d9ee0f..eb409ee45 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -335,7 +335,7 @@ teardown() { touch other-dir/.tool-versions ln -s other-dir/.tool-versions .tool-versions run asdf local "dummy" "1.1.0" - run asdf local "dummy" "1.1.0"shell wrapper function with --unset should unset ENV var + run asdf local "dummy" "1.1.0" [ "$status" -eq 0 ] [ -L .tool-versions ] [ "$(cat other-dir/.tool-versions)" = "dummy 1.1.0" ] From 67b32206d691fcef7783ab41be3dabbf070db448 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Thu, 21 Sep 2023 17:58:50 -0300 Subject: [PATCH 19/21] legacy dummy changed --- test/version_commands.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/version_commands.bats b/test/version_commands.bats index eb409ee45..ea6324ac6 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -383,9 +383,9 @@ teardown() { @test "shell wrapper function with --unset-all should unset all ENV var" { . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh" asdf shell "dummy" "1.1.0" - asdf shell "legacy-dummy" "1.2.0" + asdf shell "legacy-dummy" "latest" [ "$ASDF_DUMMY_VERSION" = "1.1.0" ] - [ "$ASDF_LEGACY_DUMMY_VERSION" = "1.0.0" ] + [ "$ASDF_LEGACY_DUMMY_VERSION" = "5.1.0" ] asdf shell --unset-all [ -z "$ASDF_DUMMY_VERSION" ] [ -z "$ASDF_LEGACY_DUMMY_VERSION" ] From 29818f37b91428544b980281eb66ba47e97fe3f5 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Fri, 22 Sep 2023 16:04:06 -0300 Subject: [PATCH 20/21] removed tests to see workflow --- test/version_commands.bats | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/test/version_commands.bats b/test/version_commands.bats index ea6324ac6..d5b15d7eb 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -380,18 +380,6 @@ teardown() { unset ASDF_DUMMY_VERSION } -@test "shell wrapper function with --unset-all should unset all ENV var" { - . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh" - asdf shell "dummy" "1.1.0" - asdf shell "legacy-dummy" "latest" - [ "$ASDF_DUMMY_VERSION" = "1.1.0" ] - [ "$ASDF_LEGACY_DUMMY_VERSION" = "5.1.0" ] - asdf shell --unset-all - [ -z "$ASDF_DUMMY_VERSION" ] - [ -z "$ASDF_LEGACY_DUMMY_VERSION" ] - unset ASDF_DUMMY_VERSION - unset ASDF_LEGACY_DUMMY_VERSION -} @test "shell wrapper function should return an error for missing plugins" { . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh" From bcb440386047b2d538b2dafad044c64aee9e8838 Mon Sep 17 00:00:00 2001 From: edvardsanta Date: Fri, 22 Sep 2023 16:07:55 -0300 Subject: [PATCH 21/21] added tests again --- test/version_commands.bats | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/version_commands.bats b/test/version_commands.bats index d5b15d7eb..ea6324ac6 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -380,6 +380,18 @@ teardown() { unset ASDF_DUMMY_VERSION } +@test "shell wrapper function with --unset-all should unset all ENV var" { + . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh" + asdf shell "dummy" "1.1.0" + asdf shell "legacy-dummy" "latest" + [ "$ASDF_DUMMY_VERSION" = "1.1.0" ] + [ "$ASDF_LEGACY_DUMMY_VERSION" = "5.1.0" ] + asdf shell --unset-all + [ -z "$ASDF_DUMMY_VERSION" ] + [ -z "$ASDF_LEGACY_DUMMY_VERSION" ] + unset ASDF_DUMMY_VERSION + unset ASDF_LEGACY_DUMMY_VERSION +} @test "shell wrapper function should return an error for missing plugins" { . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh"