diff --git a/bin/asdf b/bin/asdf index c5ad13d0..e064320e 100755 --- a/bin/asdf +++ b/bin/asdf @@ -44,71 +44,72 @@ source "$(dirname "$(dirname "$0")")/lib/commands/plugin-test.sh" # shellcheck disable=SC2124 callback_args="${@:2}" +# shellcheck disable=SC2086 case $1 in "--version") - asdf_version "$callback_args";; + asdf_version $callback_args;; "help") - help_command "$callback_args";; + help_command $callback_args;; "update") - update_command "$callback_args";; + update_command $callback_args;; "install") - install_command "$callback_args";; + install_command $callback_args;; "uninstall") - uninstall_command "$callback_args";; + uninstall_command $callback_args;; "current") - current_command "$callback_args";; + current_command $callback_args;; "where") - where_command "$callback_args";; + where_command $callback_args;; "which") - which_command "$callback_args";; + which_command $callback_args;; "local") - local_command "$callback_args";; + local_command $callback_args;; "global") - global_command "$callback_args";; + global_command $callback_args;; "list") - list_command "$callback_args";; + list_command $callback_args;; "list-all") - list_all_command "$callback_args";; + list_all_command $callback_args;; "shim") - shim_command "$callback_args";; + shim_command $callback_args;; "reshim") - reshim_command "$callback_args";; + reshim_command $callback_args;; "plugin-add") - plugin_add_command "$callback_args";; + plugin_add_command $callback_args;; "plugin-list") - plugin_list_command "$callback_args";; + plugin_list_command $callback_args;; "plugin-list-all") - plugin_list_all_command "$callback_args";; + plugin_list_all_command $callback_args;; "plugin-update") - plugin_update_command "$callback_args";; + plugin_update_command $callback_args;; "plugin-remove") - plugin_remove_command "$callback_args";; + plugin_remove_command $callback_args;; # Undocumented commands for development "plugin-push") - plugin_push_command "$callback_args";; + plugin_push_command $callback_args;; "plugin-test") - plugin_test_command "$callback_args";; + plugin_test_command $callback_args;; *) help_command diff --git a/lib/commands/plugin-test.sh b/lib/commands/plugin-test.sh index c577895a..142821a2 100644 --- a/lib/commands/plugin-test.sh +++ b/lib/commands/plugin-test.sh @@ -7,8 +7,8 @@ fail_test() { } plugin_test_command() { - export ASDF_DIR ASDF_DIR=$(mktemp -dt asdf.XXXX) + export ASDF_DIR git clone https://github.com/asdf-vm/asdf.git "$ASDF_DIR" local plugin_name=$1 @@ -19,11 +19,11 @@ plugin_test_command() { fail_test "please provide a plugin name and url" fi - if ! asdf plugin-add "$plugin_name" "$plugin_url"; then + if ! (asdf plugin-add "$plugin_name" "$plugin_url"); then fail_test "could not install $plugin_name from $plugin_url" fi - if ! asdf plugin-list | grep "$plugin_name" > /dev/null; then + if ! (asdf plugin-list | grep "$plugin_name" > /dev/null); then fail_test "$plugin_name was not properly installed" fi @@ -40,24 +40,25 @@ plugin_test_command() { local latest_version latest_version=${versions[${#versions[@]} - 1]} - if ! asdf install "$plugin_name" "$latest_version"; then + if ! (asdf install "$plugin_name" "$latest_version"); then fail_test "install exited with an error" fi cd "$ASDF_DIR" || fail_test "could not cd $ASDF_DIR" - if ! asdf local "$plugin_name" "$latest_version"; then + if ! (asdf local "$plugin_name" "$latest_version"); then fail_test "install did not add the requested version" fi - if ! asdf reshim "$plugin_name"; then + if ! (asdf reshim "$plugin_name"); then fail_test "could not reshim plugin" fi if [ -n "$plugin_command" ]; then - (env PATH="$ASDF_DIR/bin:$ASDF_DIR/shims:$PATH" eval "$plugin_command") + (PATH="$ASDF_DIR/bin:$ASDF_DIR/shims:$PATH" eval "$plugin_command") + local exit_code exit_code=$? - if [ $exit_code -ne 0 ]; then + if [ $exit_code != 0 ]; then fail_test "$plugin_command failed with exit code $?" fi fi