Skip to content

Commit

Permalink
fix: Fix plugin-test arg parsing (#1084)
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 authored Nov 7, 2021
1 parent 4321980 commit c911f2d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/commands/command-plugin-test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@ plugin_test_command() {
local plugin_gitref="master"
local tool_version
local interpret_args_literally
local skip_next_arg

for arg; do
shift
if [ -n "${interpret_args_literally}" ]; then
if [ -n "${skip_next_arg}" ]; then
skip_next_arg=
elif [ -n "${interpret_args_literally}" ]; then
set -- "$@" "${arg}"
else
case "${arg}" in
--asdf-plugin-gitref)
plugin_gitref="$2"
shift 2
plugin_gitref="$1"
skip_next_arg=true
;;
--asdf-tool-version)
tool_version="$2"
shift 2
tool_version="$1"
skip_next_arg=true
;;
--)
interpret_args_literally=true
shift
;;
*)
set -- "$@" "${arg}"
Expand Down
20 changes: 20 additions & 0 deletions test/fixtures/dummy_plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2014 Akash Manohar J

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15 changes: 15 additions & 0 deletions test/plugin_test_command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load test_helpers

setup() {
setup_asdf_dir
install_mock_plugin_repo "dummy"
}

teardown() {
Expand All @@ -21,3 +22,17 @@ teardown() {
[ "$status" -eq 1 ]
[ "$output" = "FAILED: please provide a plugin name and url" ]
}

@test "plugin_test_command works with no options provided" {
run asdf plugin-test dummy "${BASE_DIR}/repo-dummy"
echo "status = ${status}"
echo "output = ${output}"
[ "$status" -eq 0 ]
}

@test "plugin_test_command works with all options provided" {
run asdf plugin-test dummy "${BASE_DIR}/repo-dummy" --asdf-tool-version 1.0.0 --asdf-plugin-gitref master
echo "status = ${status}"
echo "output = ${output}"
[ "$status" -eq 0 ]
}

0 comments on commit c911f2d

Please sign in to comment.