ci: add latest OSs to testing matrix, bump BATS, shfmt, shellcheck (#1260)

* ci: add latest OSs to testing matrix
* ci: bump bats & shellcheck & shfmt
* chore: format with latest shfmt
This commit is contained in:
James Hegedus 2022-06-24 19:20:27 +10:00 committed by GitHub
parent b1842b1b8e
commit 21bc411915
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 195 additions and 195 deletions

View File

@ -7,7 +7,7 @@ on:
pull_request: pull_request:
env: env:
BATS_VERSION: v1.3.0 BATS_VERSION: v1.7.0
jobs: jobs:
nix: nix:
@ -16,9 +16,11 @@ jobs:
matrix: matrix:
os: os:
- macos-10.15 - macos-10.15
# - macos-11 - enable once out of private preview: https://github.com/actions/virtual-environments#available-environments - macos-11
- macos-12
- ubuntu-18.04 - ubuntu-18.04
- ubuntu-20.04 - ubuntu-20.04
- ubuntu-22.04
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout code - name: Checkout code

View File

@ -1,3 +1,3 @@
bats 1.3.0 bats 1.7.0
shellcheck 0.7.2 shellcheck 0.8.0
shfmt 3.3.0 shfmt 3.5.1

View File

@ -25,18 +25,18 @@ cleaned_path() {
} }
@test "adds asdf dirs to PATH" { @test "adds asdf dirs to PATH" {
result=$(fish -c " result=$(fish -c "
set -e asdf set -e asdf
set -e ASDF_DIR set -e ASDF_DIR
set -e ASDF_DATA_DIR set -e ASDF_DATA_DIR
set PATH $(cleaned_path) set PATH $(cleaned_path)
. (pwd)/asdf.fish # if the full path is not passed, status -f will return the relative path . (pwd)/asdf.fish # if the full path is not passed, status -f will return the relative path
echo \$PATH echo \$PATH
") ")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
output=$(echo "$result" | grep "asdf") output=$(echo "$result" | grep "asdf")
[ "$output" != "" ] [ "$output" != "" ]
} }
@test "does not add paths to PATH more than once" { @test "does not add paths to PATH more than once" {
@ -81,4 +81,3 @@ cleaned_path() {
output=$(echo "$result" | grep "ASDF INSTALLED PLUGINS:") output=$(echo "$result" | grep "ASDF INSTALLED PLUGINS:")
[ "$output" != "" ] [ "$output" != "" ]
} }

View File

@ -3,50 +3,50 @@
load test_helpers load test_helpers
banned_commands=( banned_commands=(
# Process substitution isn't POSIX compliant and cause trouble # Process substitution isn't POSIX compliant and cause trouble
"<(" "<("
# Command isn't included in the Ubuntu packages asdf depends on. Also not # Command isn't included in the Ubuntu packages asdf depends on. Also not
# defined in POSIX # defined in POSIX
column column
# echo isn't consistent across operating systems, and sometimes output can # echo isn't consistent across operating systems, and sometimes output can
# be confused with echo flags. printf does everything echo does and more. # be confused with echo flags. printf does everything echo does and more.
echo echo
# It's best to avoid eval as it makes it easier to accidentally execute # It's best to avoid eval as it makes it easier to accidentally execute
# arbitrary strings # arbitrary strings
eval eval
# realpath not available by default on OSX. # realpath not available by default on OSX.
realpath realpath
# readlink on OSX behaves differently from readlink on other Unix systems # readlink on OSX behaves differently from readlink on other Unix systems
readlink readlink
# source isn't POSIX compliant. . behaves the same and is POSIX compliant # source isn't POSIX compliant. . behaves the same and is POSIX compliant
# Except in fish, where . is deprecated, and will be removed in the future. # Except in fish, where . is deprecated, and will be removed in the future.
source source
) )
banned_commands_regex=( banned_commands_regex=(
# grep -y does not work on alpine and should be "grep -i" either way # grep -y does not work on alpine and should be "grep -i" either way
"grep.* -y" "grep.* -y"
# grep -P is not a valid option in OSX. # grep -P is not a valid option in OSX.
"grep.* -P" "grep.* -P"
# Ban grep long commands as they do not work on alpine # Ban grep long commands as they do not work on alpine
"grep[^|]+--\w{2,}" "grep[^|]+--\w{2,}"
# sort --sort-version isn't supported everywhere # sort --sort-version isn't supported everywhere
"sort.*-V" "sort.*-V"
"sort.*--sort-versions" "sort.*--sort-versions"
# ls often gets used when we want to glob for files that match a pattern # ls often gets used when we want to glob for files that match a pattern
# or when we want to find all files/directories that match a pattern or are # or when we want to find all files/directories that match a pattern or are
# found in a certain location. Using shell globs is preferred over ls, and # found in a certain location. Using shell globs is preferred over ls, and
# find is better at locating files that are in a certain location or that # find is better at locating files that are in a certain location or that
# match certain filename patterns. # match certain filename patterns.
# https://github-wiki-see.page/m/koalaman/shellcheck/wiki/SC2012 # https://github-wiki-see.page/m/koalaman/shellcheck/wiki/SC2012
'\bls ' '\bls '
# Ban recusive asdf calls as they are inefficient and may introduce bugs. # Ban recusive asdf calls as they are inefficient and may introduce bugs.
# If you find yourself needing to invoke an `asdf` command from within # If you find yourself needing to invoke an `asdf` command from within
# asdf code, please source the appropriate file and invoke the # asdf code, please source the appropriate file and invoke the
# corresponding function. # corresponding function.
'\basdf ' '\basdf '
) )
setup() { setup() {
@ -64,36 +64,36 @@ teardown() {
# followed by an underscore (indicating it's a variable and not a # followed by an underscore (indicating it's a variable and not a
# command). # command).
for cmd in "${banned_commands[@]}"; do for cmd in "${banned_commands[@]}"; do
run bash -c "grep -nHR --include \*.bash --include \*.sh '$cmd' asdf.* lib bin\ run bash -c "grep -nHR --include \*.bash --include \*.sh '$cmd' asdf.* lib bin\
| grep -v '#.*$cmd'\ | grep -v '#.*$cmd'\
| grep -v '\".*$cmd.*\"' \ | grep -v '\".*$cmd.*\"' \
| grep -v '${cmd}_'\ | grep -v '${cmd}_'\
| grep -v '# asdf_allow: $cmd'" | grep -v '# asdf_allow: $cmd'"
# Only print output if we've found a banned command # Only print output if we've found a banned command
#if [ "$status" -ne 1 ]; then #if [ "$status" -ne 1 ]; then
if [ "" != "$output" ]; then if [ "" != "$output" ]; then
echo "banned command $cmd: $output" echo "banned command $cmd: $output"
fi fi
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "" == "$output" ] [ "" == "$output" ]
done done
for cmd in "${banned_commands_regex[@]}"; do for cmd in "${banned_commands_regex[@]}"; do
run bash -c "grep -nHRE --include \*.bash --include \*.sh '$cmd' asdf.* lib bin\ run bash -c "grep -nHRE --include \*.bash --include \*.sh '$cmd' asdf.* lib bin\
| grep -v '#.*$cmd'\ | grep -v '#.*$cmd'\
| grep -v '\".*$cmd.*\"' \ | grep -v '\".*$cmd.*\"' \
| grep -v '${cmd}_'\ | grep -v '${cmd}_'\
| grep -v '# asdf_allow: $cmd'" | grep -v '# asdf_allow: $cmd'"
# Only print output if we've found a banned command # Only print output if we've found a banned command
#if [ "$status" -ne 1 ]; then #if [ "$status" -ne 1 ]; then
if [ "" != "$output" ]; then if [ "" != "$output" ]; then
echo "banned command $cmd: $output" echo "banned command $cmd: $output"
fi fi
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "" == "$output" ] [ "" == "$output" ]
done done
} }

View File

@ -3,15 +3,15 @@
load test_helpers load test_helpers
setup() { setup() {
cd $BATS_TMPDIR cd $BATS_TMPDIR
ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc ASDF_CONFIG_FILE=$BATS_TMPDIR/asdfrc
cat > $ASDF_CONFIG_FILE <<-EOM cat >$ASDF_CONFIG_FILE <<-EOM
key1 = value1 key1 = value1
legacy_version_file = yes legacy_version_file = yes
EOM EOM
ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults
cat > $ASDF_CONFIG_DEFAULT_FILE <<-EOM cat >$ASDF_CONFIG_DEFAULT_FILE <<-EOM
# i have a comment, it's ok # i have a comment, it's ok
key2 = value2 key2 = value2
legacy_version_file = no legacy_version_file = no
@ -19,30 +19,30 @@ EOM
} }
teardown() { teardown() {
rm $ASDF_CONFIG_FILE rm $ASDF_CONFIG_FILE
rm $ASDF_CONFIG_DEFAULT_FILE rm $ASDF_CONFIG_DEFAULT_FILE
unset ASDF_CONFIG_DEFAULT_FILE unset ASDF_CONFIG_DEFAULT_FILE
unset ASDF_CONFIG_FILE unset ASDF_CONFIG_FILE
} }
@test "get_config returns default when config file does not exist" { @test "get_config returns default when config file does not exist" {
result=$(ASDF_CONFIG_FILE="/some/fake/path" get_asdf_config_value "legacy_version_file") result=$(ASDF_CONFIG_FILE="/some/fake/path" get_asdf_config_value "legacy_version_file")
[ "$result" = "no" ] [ "$result" = "no" ]
} }
@test "get_config returns default value when the key does not exist" { @test "get_config returns default value when the key does not exist" {
[ $(get_asdf_config_value "key2") = "value2" ] [ $(get_asdf_config_value "key2") = "value2" ]
} }
@test "get_config returns config file value when key exists" { @test "get_config returns config file value when key exists" {
[ $(get_asdf_config_value "key1") = "value1" ] [ $(get_asdf_config_value "key1") = "value1" ]
[ $(get_asdf_config_value "legacy_version_file") = "yes" ] [ $(get_asdf_config_value "legacy_version_file") = "yes" ]
} }
@test "get_config returns config file complete value including '=' symbols" { @test "get_config returns config file complete value including '=' symbols" {
cat >> $ASDF_CONFIG_FILE <<-'EOM' cat >>$ASDF_CONFIG_FILE <<-'EOM'
key3 = VAR=val key3 = VAR=val
EOM EOM
[ $(get_asdf_config_value "key3") = "VAR=val" ] [ $(get_asdf_config_value "key3") = "VAR=val" ]
} }

View File

@ -22,12 +22,13 @@ teardown() {
run asdf help "dummy" run asdf help "dummy"
expected_output="$(cat <<EOF expected_output="$(
cat <<EOF
Dummy plugin documentation Dummy plugin documentation
Dummy plugin is a plugin only used for unit tests Dummy plugin is a plugin only used for unit tests
EOF EOF
)" )"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "$expected_output" ] [ "$output" = "$expected_output" ]
} }
@ -37,14 +38,15 @@ EOF
run asdf help "dummy" "1.2.3" run asdf help "dummy" "1.2.3"
expected_output="$(cat <<EOF expected_output="$(
cat <<EOF
Dummy plugin documentation Dummy plugin documentation
Dummy plugin is a plugin only used for unit tests Dummy plugin is a plugin only used for unit tests
Details specific for version 1.2.3 Details specific for version 1.2.3
EOF EOF
)" )"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
echo $output echo $output
[ "$output" = "$expected_output" ] [ "$output" = "$expected_output" ]

View File

@ -30,7 +30,7 @@ teardown() {
@test "install_command without arguments installs even if the user is terrible and does not use newlines" { @test "install_command without arguments installs even if the user is terrible and does not use newlines" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo -n 'dummy 1.2.0' > ".tool-versions" echo -n 'dummy 1.2.0' >".tool-versions"
run asdf install run asdf install
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ $(cat $ASDF_DIR/installs/dummy/1.2.0/version) = "1.2.0" ] [ $(cat $ASDF_DIR/installs/dummy/1.2.0/version) = "1.2.0" ]
@ -38,7 +38,7 @@ teardown() {
@test "install_command with only name installs the version in .tool-versions" { @test "install_command with only name installs the version in .tool-versions" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo -n 'dummy 1.2.0' > ".tool-versions" echo -n 'dummy 1.2.0' >".tool-versions"
run asdf install dummy run asdf install dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ $(cat $ASDF_DIR/installs/dummy/1.2.0/version) = "1.2.0" ] [ $(cat $ASDF_DIR/installs/dummy/1.2.0/version) = "1.2.0" ]
@ -56,7 +56,7 @@ teardown() {
WHITESPACE_DIR="$PROJECT_DIR/whitespace\ dir" WHITESPACE_DIR="$PROJECT_DIR/whitespace\ dir"
mkdir -p "$WHITESPACE_DIR" mkdir -p "$WHITESPACE_DIR"
cd "$WHITESPACE_DIR" cd "$WHITESPACE_DIR"
echo 'dummy 1.2.0' >> "$WHITESPACE_DIR/.tool-versions" echo 'dummy 1.2.0' >>"$WHITESPACE_DIR/.tool-versions"
run asdf install run asdf install
@ -104,7 +104,7 @@ teardown() {
@test "install_command without arguments should not generate shim for subdir" { @test "install_command without arguments should not generate shim for subdir" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo 'dummy 1.0.0' > $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0' >$PROJECT_DIR/.tool-versions
run asdf install run asdf install
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -117,7 +117,7 @@ teardown() {
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/ cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
cd $PROJECT_DIR cd $PROJECT_DIR
echo 'dummy 1.0.0' > $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0' >$PROJECT_DIR/.tool-versions
run asdf install run asdf install
# execute the generated shim # execute the generated shim
@ -135,24 +135,24 @@ teardown() {
@test "install_command fails if the plugin is not installed" { @test "install_command fails if the plugin is not installed" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo 'other_dummy 1.0.0' > $PROJECT_DIR/.tool-versions echo 'other_dummy 1.0.0' >$PROJECT_DIR/.tool-versions
run asdf install run asdf install
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "$output" = "other_dummy plugin is not installed" ] [ "$output" = "other_dummy plugin is not installed" ]
} }
@test "install_command fails if the plugin is not installed without collisions" { @test "install_command fails if the plugin is not installed without collisions" {
cd $PROJECT_DIR cd $PROJECT_DIR
printf "dummy 1.0.0\ndum 1.0.0" > $PROJECT_DIR/.tool-versions printf "dummy 1.0.0\ndum 1.0.0" >$PROJECT_DIR/.tool-versions
run asdf install run asdf install
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "$output" = "dum plugin is not installed" ] [ "$output" = "dum plugin is not installed" ]
} }
@test "install_command fails when tool is specified but no version of the tool is configured in config file" { @test "install_command fails when tool is specified but no version of the tool is configured in config file" {
echo 'dummy 1.0.0' > $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0' >$PROJECT_DIR/.tool-versions
run asdf install other-dummy run asdf install other-dummy
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "$output" = "No versions specified for other-dummy in config files or environment" ] [ "$output" = "No versions specified for other-dummy in config files or environment" ]
@ -160,7 +160,7 @@ teardown() {
} }
@test "install_command fails when two tools are specified with no versions" { @test "install_command fails when two tools are specified with no versions" {
printf 'dummy 1.0.0\nother-dummy 2.0.0' > $PROJECT_DIR/.tool-versions printf 'dummy 1.0.0\nother-dummy 2.0.0' >$PROJECT_DIR/.tool-versions
run asdf install dummy other-dummy run asdf install dummy other-dummy
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "$output" = "Dummy couldn't install version: other-dummy (on purpose)" ] [ "$output" = "Dummy couldn't install version: other-dummy (on purpose)" ]
@ -172,7 +172,7 @@ teardown() {
# asdf lib needed to run generated shims # asdf lib needed to run generated shims
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/ cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
echo 'dummy 1.0.0' > $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0' >$PROJECT_DIR/.tool-versions
mkdir -p $PROJECT_DIR/child mkdir -p $PROJECT_DIR/child
cd $PROJECT_DIR/child cd $PROJECT_DIR/child
@ -185,7 +185,7 @@ teardown() {
} }
@test "install_command installs multiple tool versions when they are specified in a .tool-versions file" { @test "install_command installs multiple tool versions when they are specified in a .tool-versions file" {
echo 'dummy 1.0.0 1.2.0' > $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0 1.2.0' >$PROJECT_DIR/.tool-versions
cd $PROJECT_DIR cd $PROJECT_DIR
run asdf install run asdf install
@ -203,7 +203,7 @@ teardown() {
} }
@test "install command executes configured pre plugin install hook" { @test "install command executes configured pre plugin install hook" {
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
pre_asdf_install_dummy = echo will install dummy $1 pre_asdf_install_dummy = echo will install dummy $1
EOM EOM
@ -212,7 +212,7 @@ EOM
} }
@test "install command executes configured post plugin install hook" { @test "install command executes configured post plugin install hook" {
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
post_asdf_install_dummy = echo HEY $version FROM $plugin_name post_asdf_install_dummy = echo HEY $version FROM $plugin_name
EOM EOM
@ -221,8 +221,8 @@ EOM
} }
@test "install command without arguments installs versions from legacy files" { @test "install command without arguments installs versions from legacy files" {
echo 'legacy_version_file = yes' > $HOME/.asdfrc echo 'legacy_version_file = yes' >$HOME/.asdfrc
echo '1.2.0' >> $PROJECT_DIR/.dummy-version echo '1.2.0' >>$PROJECT_DIR/.dummy-version
cd $PROJECT_DIR cd $PROJECT_DIR
run asdf install run asdf install
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -231,8 +231,8 @@ EOM
} }
@test "install command without arguments installs versions from legacy files in parent directories" { @test "install command without arguments installs versions from legacy files in parent directories" {
echo 'legacy_version_file = yes' > $HOME/.asdfrc echo 'legacy_version_file = yes' >$HOME/.asdfrc
echo '1.2.0' >> $PROJECT_DIR/.dummy-version echo '1.2.0' >>$PROJECT_DIR/.dummy-version
mkdir -p $PROJECT_DIR/child mkdir -p $PROJECT_DIR/child
cd $PROJECT_DIR/child cd $PROJECT_DIR/child
@ -270,7 +270,7 @@ EOM
} }
@test "install_command keeps the download directory when always_keep_download setting is true" { @test "install_command keeps the download directory when always_keep_download setting is true" {
echo 'always_keep_download = yes' > $HOME/.asdfrc echo 'always_keep_download = yes' >$HOME/.asdfrc
run asdf install dummy 1.1.0 run asdf install dummy 1.1.0
echo $output echo $output
[ "$status" -eq 0 ] [ "$status" -eq 0 ]

View File

@ -93,7 +93,7 @@ teardown() {
@test "plugin_add command executes configured pre hook (generic)" { @test "plugin_add command executes configured pre hook (generic)" {
install_mock_plugin_repo "dummy" install_mock_plugin_repo "dummy"
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
pre_asdf_plugin_add = echo ADD ${@} pre_asdf_plugin_add = echo ADD ${@}
EOM EOM
@ -107,7 +107,7 @@ plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy"
@test "plugin_add command executes configured pre hook (specific)" { @test "plugin_add command executes configured pre hook (specific)" {
install_mock_plugin_repo "dummy" install_mock_plugin_repo "dummy"
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
pre_asdf_plugin_add_dummy = echo ADD pre_asdf_plugin_add_dummy = echo ADD
EOM EOM
@ -121,7 +121,7 @@ plugin add path=${ASDF_DIR}/plugins/dummy source_url=${BASE_DIR}/repo-dummy"
@test "plugin_add command executes configured post hook (generic)" { @test "plugin_add command executes configured post hook (generic)" {
install_mock_plugin_repo "dummy" install_mock_plugin_repo "dummy"
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
post_asdf_plugin_add = echo ADD ${@} post_asdf_plugin_add = echo ADD ${@}
EOM EOM
@ -135,7 +135,7 @@ ADD dummy"
@test "plugin_add command executes configured post hook (specific)" { @test "plugin_add command executes configured post hook (specific)" {
install_mock_plugin_repo "dummy" install_mock_plugin_repo "dummy"
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
post_asdf_plugin_add_dummy = echo ADD post_asdf_plugin_add_dummy = echo ADD
EOM EOM

View File

@ -54,7 +54,7 @@ teardown() {
plugin_path="$(get_plugin_path dummy)" plugin_path="$(get_plugin_path dummy)"
# this plugin defines a new `asdf dummy foo` command # this plugin defines a new `asdf dummy foo` command
cat <<'EOF' > "$plugin_path/lib/commands/command-foo.bash" cat <<'EOF' >"$plugin_path/lib/commands/command-foo.bash"
#!/usr/bin/env bash #!/usr/bin/env bash
echo this is an executable $* echo this is an executable $*
EOF EOF
@ -71,7 +71,7 @@ EOF
plugin_path="$(get_plugin_path dummy)" plugin_path="$(get_plugin_path dummy)"
# this plugin defines a new `asdf dummy foo` command # this plugin defines a new `asdf dummy foo` command
echo 'echo sourced script has asdf utils $(get_plugin_path dummy) $*' > "$plugin_path/lib/commands/command-foo.bash" echo 'echo sourced script has asdf utils $(get_plugin_path dummy) $*' >"$plugin_path/lib/commands/command-foo.bash"
expected="sourced script has asdf utils $plugin_path bar" expected="sourced script has asdf utils $plugin_path bar"
@ -84,7 +84,7 @@ EOF
plugin_path="$(get_plugin_path dummy)" plugin_path="$(get_plugin_path dummy)"
# this plugin defines a new `asdf dummy` command # this plugin defines a new `asdf dummy` command
cat <<'EOF' > "$plugin_path/lib/commands/command.bash" cat <<'EOF' >"$plugin_path/lib/commands/command.bash"
#!/usr/bin/env bash #!/usr/bin/env bash
echo hello echo hello
EOF EOF
@ -101,7 +101,7 @@ EOF
plugin_path="$(get_plugin_path dummy)" plugin_path="$(get_plugin_path dummy)"
# this plugin defines a new `asdf dummy` command # this plugin defines a new `asdf dummy` command
cat <<'EOF' > "$plugin_path/lib/commands/command.bash" cat <<'EOF' >"$plugin_path/lib/commands/command.bash"
#!/usr/bin/env bash #!/usr/bin/env bash
echo hello $* echo hello $*
EOF EOF

View File

@ -13,7 +13,7 @@ teardown() {
} }
@test "plugin_list_all should sync repo when check_duration set to 0" { @test "plugin_list_all should sync repo when check_duration set to 0" {
echo 'plugin_repository_last_check_duration = 0' > $HOME/.asdfrc echo 'plugin_repository_last_check_duration = 0' >$HOME/.asdfrc
run asdf plugin-list-all run asdf plugin-list-all
local expected_plugin_repo_sync="updating plugin repository..." local expected_plugin_repo_sync="updating plugin repository..."
local expected_plugins_list="\ local expected_plugins_list="\
@ -27,7 +27,7 @@ foo http://example.com/foo"
} }
@test "plugin_list_all no immediate repo sync expected because check_duration is greater than 0" { @test "plugin_list_all no immediate repo sync expected because check_duration is greater than 0" {
echo 'plugin_repository_last_check_duration = 10' > $HOME/.asdfrc echo 'plugin_repository_last_check_duration = 10' >$HOME/.asdfrc
run asdf plugin-list-all run asdf plugin-list-all
local expected="\ local expected="\
bar http://example.com/bar bar http://example.com/bar
@ -39,7 +39,7 @@ foo http://example.com/foo"
} }
@test "plugin_list_all skips repo sync because check_duration is set to never" { @test "plugin_list_all skips repo sync because check_duration is set to never" {
echo 'plugin_repository_last_check_duration = never' > $HOME/.asdfrc echo 'plugin_repository_last_check_duration = never' >$HOME/.asdfrc
run asdf plugin-list-all run asdf plugin-list-all
local expected="\ local expected="\
bar http://example.com/bar bar http://example.com/bar

View File

@ -16,7 +16,6 @@ teardown() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ -d "$ASDF_DIR/downloads/dummy" ] [ -d "$ASDF_DIR/downloads/dummy" ]
run asdf plugin-remove "dummy" run asdf plugin-remove "dummy"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ ! -d "$ASDF_DIR/downloads/dummy" ] [ ! -d "$ASDF_DIR/downloads/dummy" ]

View File

@ -57,7 +57,7 @@ teardown() {
run asdf install dummy 1.0 run asdf install dummy 1.0
# make an unrelated shim # make an unrelated shim
echo "# asdf-plugin: gummy" > $ASDF_DIR/shims/gummy echo "# asdf-plugin: gummy" >$ASDF_DIR/shims/gummy
run asdf plugin-remove dummy run asdf plugin-remove dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -77,7 +77,7 @@ teardown() {
@test "plugin_remove_command executes configured pre hook (generic)" { @test "plugin_remove_command executes configured pre hook (generic)" {
install_dummy_plugin install_dummy_plugin
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
pre_asdf_plugin_remove = echo REMOVE ${@} pre_asdf_plugin_remove = echo REMOVE ${@}
EOM EOM
@ -91,7 +91,7 @@ plugin-remove ${ASDF_DIR}/plugins/dummy"
@test "plugin_remove_command executes configured pre hook (specific)" { @test "plugin_remove_command executes configured pre hook (specific)" {
install_dummy_plugin install_dummy_plugin
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
pre_asdf_plugin_remove_dummy = echo REMOVE pre_asdf_plugin_remove_dummy = echo REMOVE
EOM EOM
@ -105,7 +105,7 @@ plugin-remove ${ASDF_DIR}/plugins/dummy"
@test "plugin_remove_command executes configured post hook (generic)" { @test "plugin_remove_command executes configured post hook (generic)" {
install_dummy_plugin install_dummy_plugin
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
post_asdf_plugin_remove = echo REMOVE ${@} post_asdf_plugin_remove = echo REMOVE ${@}
EOM EOM
@ -119,7 +119,7 @@ REMOVE dummy"
@test "plugin_remove_command executes configured post hook (specific)" { @test "plugin_remove_command executes configured post hook (specific)" {
install_dummy_plugin install_dummy_plugin
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
post_asdf_plugin_remove_dummy = echo REMOVE post_asdf_plugin_remove_dummy = echo REMOVE
EOM EOM

View File

@ -14,7 +14,6 @@ teardown() {
clean_asdf_dir clean_asdf_dir
} }
@test "reshim should allow prefixes of other versions" { @test "reshim should allow prefixes of other versions" {
run asdf install dummy 1.0.1 run asdf install dummy 1.0.1
run asdf install dummy 1.0 run asdf install dummy 1.0
@ -123,7 +122,7 @@ teardown() {
@test "reshim command executes configured pre hook" { @test "reshim command executes configured pre hook" {
run asdf install dummy 1.0 run asdf install dummy 1.0
cat > "$HOME/.asdfrc" <<-'EOM' cat >"$HOME/.asdfrc" <<-'EOM'
pre_asdf_reshim_dummy = echo RESHIM pre_asdf_reshim_dummy = echo RESHIM
EOM EOM
@ -134,7 +133,7 @@ EOM
@test "reshim command executes configured post hook" { @test "reshim command executes configured post hook" {
run asdf install dummy 1.0 run asdf install dummy 1.0
cat > "$HOME/.asdfrc" <<-'EOM' cat >"$HOME/.asdfrc" <<-'EOM'
post_asdf_reshim_dummy = echo RESHIM post_asdf_reshim_dummy = echo RESHIM
EOM EOM

View File

@ -25,7 +25,7 @@ teardown() {
} }
@test "asdf env should execute under the environment used for a shim" { @test "asdf env should execute under the environment used for a shim" {
echo "dummy 1.0" > $PROJECT_DIR/.tool-versions echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
run asdf install run asdf install
run asdf env dummy which dummy run asdf env dummy which dummy
@ -33,12 +33,11 @@ teardown() {
[ "$output" == "$ASDF_DIR/installs/dummy/1.0/bin/dummy" ] [ "$output" == "$ASDF_DIR/installs/dummy/1.0/bin/dummy" ]
} }
@test "asdf env should execute under plugin custom environment used for a shim" { @test "asdf env should execute under plugin custom environment used for a shim" {
echo "dummy 1.0" > $PROJECT_DIR/.tool-versions echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
run asdf install run asdf install
echo "export FOO=bar" > $ASDF_DIR/plugins/dummy/bin/exec-env echo "export FOO=bar" >$ASDF_DIR/plugins/dummy/bin/exec-env
chmod +x $ASDF_DIR/plugins/dummy/bin/exec-env chmod +x $ASDF_DIR/plugins/dummy/bin/exec-env
run asdf env dummy run asdf env dummy
@ -47,13 +46,13 @@ teardown() {
} }
@test "asdf env should ignore plugin custom environment on system version" { @test "asdf env should ignore plugin custom environment on system version" {
echo "dummy 1.0" > $PROJECT_DIR/.tool-versions echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
run asdf install run asdf install
echo "export FOO=bar" > $ASDF_DIR/plugins/dummy/bin/exec-env echo "export FOO=bar" >$ASDF_DIR/plugins/dummy/bin/exec-env
chmod +x $ASDF_DIR/plugins/dummy/bin/exec-env chmod +x $ASDF_DIR/plugins/dummy/bin/exec-env
echo "dummy system" > $PROJECT_DIR/.tool-versions echo "dummy system" >$PROJECT_DIR/.tool-versions
run asdf env dummy run asdf env dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -68,7 +67,7 @@ teardown() {
} }
@test "asdf env should set PATH correctly" { @test "asdf env should set PATH correctly" {
echo "dummy 1.0" > $PROJECT_DIR/.tool-versions echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
run asdf install run asdf install
run asdf env dummy run asdf env dummy

View File

@ -25,14 +25,14 @@ teardown() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ] [ $(cat $ASDF_DIR/installs/dummy/1.1.0/version) = "1.1.0" ]
run asdf uninstall dummy 1.1.0 run asdf uninstall dummy 1.1.0
[ ! -f $ASDF_DIR/installs/dummy/1.1.0/version ] [ ! -f $ASDF_DIR/installs/dummy/1.1.0/version ]
} }
@test "uninstall_command should invoke the plugin bin/uninstall if available" { @test "uninstall_command should invoke the plugin bin/uninstall if available" {
run asdf install dummy 1.1.0 run asdf install dummy 1.1.0
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
mkdir -p $ASDF_DIR/plugins/dummy/bin mkdir -p $ASDF_DIR/plugins/dummy/bin
echo "echo custom uninstall" > $ASDF_DIR/plugins/dummy/bin/uninstall echo "echo custom uninstall" >$ASDF_DIR/plugins/dummy/bin/uninstall
chmod 755 $ASDF_DIR/plugins/dummy/bin/uninstall chmod 755 $ASDF_DIR/plugins/dummy/bin/uninstall
run asdf uninstall dummy 1.1.0 run asdf uninstall dummy 1.1.0
[ "$output" == "custom uninstall" ] [ "$output" == "custom uninstall" ]
@ -84,7 +84,7 @@ teardown() {
} }
@test "uninstall command executes configured pre hook" { @test "uninstall command executes configured pre hook" {
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
pre_asdf_uninstall_dummy = echo will uninstall dummy $1 pre_asdf_uninstall_dummy = echo will uninstall dummy $1
EOM EOM
@ -94,7 +94,7 @@ EOM
} }
@test "uninstall command executes configured post hook" { @test "uninstall command executes configured post hook" {
cat > $HOME/.asdfrc <<-'EOM' cat >$HOME/.asdfrc <<-'EOM'
post_asdf_uninstall_dummy = echo removed dummy $1 post_asdf_uninstall_dummy = echo removed dummy $1
EOM EOM

View File

@ -45,7 +45,7 @@ teardown() {
@test "asdf update should checkout the latest tag when configured with use_release_candidates = yes" { @test "asdf update should checkout the latest tag when configured with use_release_candidates = yes" {
local tag=$(git tag | tail -1) local tag=$(git tag | tail -1)
export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults export ASDF_CONFIG_DEFAULT_FILE=$BATS_TMPDIR/asdfrc_defaults
echo "use_release_candidates = yes" > $ASDF_CONFIG_DEFAULT_FILE echo "use_release_candidates = yes" >$ASDF_CONFIG_DEFAULT_FILE
run asdf update run asdf update
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
cd $ASDF_DIR cd $ASDF_DIR

View File

@ -110,7 +110,7 @@ teardown() {
} }
@test "parse_asdf_version_file should output version" { @test "parse_asdf_version_file should output version" {
echo "dummy 0.1.0" > $PROJECT_DIR/.tool-versions echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "0.1.0" ] [ "$output" == "0.1.0" ]
@ -120,22 +120,22 @@ teardown() {
PROJECT_DIR="$PROJECT_DIR/outer space" PROJECT_DIR="$PROJECT_DIR/outer space"
mkdir -p "$PROJECT_DIR" mkdir -p "$PROJECT_DIR"
cd $outer cd $outer
echo "dummy 0.1.0" > "$PROJECT_DIR/.tool-versions" echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions"
run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "0.1.0" ] [ "$output" == "0.1.0" ]
} }
@test "parse_asdf_version_file should output path version with spaces" { @test "parse_asdf_version_file should output path version with spaces" {
echo "dummy path:/some/dummy path" > $PROJECT_DIR/.tool-versions echo "dummy path:/some/dummy path" >$PROJECT_DIR/.tool-versions
run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "path:/some/dummy path" ] [ "$output" == "path:/some/dummy path" ]
} }
@test "find_versions should return .tool-versions if legacy is disabled" { @test "find_versions should return .tool-versions if legacy is disabled" {
echo "dummy 0.1.0" > $PROJECT_DIR/.tool-versions echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
echo "0.2.0" > $PROJECT_DIR/.dummy-version echo "0.2.0" >$PROJECT_DIR/.dummy-version
run find_versions "dummy" $PROJECT_DIR run find_versions "dummy" $PROJECT_DIR
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -143,9 +143,9 @@ teardown() {
} }
@test "find_versions should return the legacy file if supported" { @test "find_versions should return the legacy file if supported" {
echo "legacy_version_file = yes" > $HOME/.asdfrc echo "legacy_version_file = yes" >$HOME/.asdfrc
echo "dummy 0.1.0" > $HOME/.tool-versions echo "dummy 0.1.0" >$HOME/.tool-versions
echo "0.2.0" > $PROJECT_DIR/.dummy-version echo "0.2.0" >$PROJECT_DIR/.dummy-version
run find_versions "dummy" $PROJECT_DIR run find_versions "dummy" $PROJECT_DIR
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -153,8 +153,8 @@ teardown() {
} }
@test "find_versions skips .tool-version file that don't list the plugin" { @test "find_versions skips .tool-version file that don't list the plugin" {
echo "dummy 0.1.0" > $HOME/.tool-versions echo "dummy 0.1.0" >$HOME/.tool-versions
echo "another_plugin 0.3.0" > $PROJECT_DIR/.tool-versions echo "another_plugin 0.3.0" >$PROJECT_DIR/.tool-versions
run find_versions "dummy" $PROJECT_DIR run find_versions "dummy" $PROJECT_DIR
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -162,9 +162,9 @@ teardown() {
} }
@test "find_versions should return .tool-versions if unsupported" { @test "find_versions should return .tool-versions if unsupported" {
echo "dummy 0.1.0" > $HOME/.tool-versions echo "dummy 0.1.0" >$HOME/.tool-versions
echo "0.2.0" > $PROJECT_DIR/.dummy-version echo "0.2.0" >$PROJECT_DIR/.dummy-version
echo "legacy_version_file = yes" > $HOME/.asdfrc echo "legacy_version_file = yes" >$HOME/.asdfrc
rm $ASDF_DIR/plugins/dummy/bin/list-legacy-filenames rm $ASDF_DIR/plugins/dummy/bin/list-legacy-filenames
run find_versions "dummy" $PROJECT_DIR run find_versions "dummy" $PROJECT_DIR
@ -213,7 +213,7 @@ teardown() {
@test "find_versions should return \$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" { @test "find_versions should return \$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" {
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$PROJECT_DIR/global-tool-versions" ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$PROJECT_DIR/global-tool-versions"
echo "dummy 0.1.0" > $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME echo "dummy 0.1.0" >$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
run find_versions "dummy" $PROJECT_DIR run find_versions "dummy" $PROJECT_DIR
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -222,9 +222,9 @@ teardown() {
@test "find_versions should check \$HOME legacy files before \$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" { @test "find_versions should check \$HOME legacy files before \$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" {
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$PROJECT_DIR/global-tool-versions" ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="$PROJECT_DIR/global-tool-versions"
echo "dummy 0.2.0" > $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME echo "dummy 0.2.0" >$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
echo "dummy 0.1.0" > $HOME/.dummy-version echo "dummy 0.1.0" >$HOME/.dummy-version
echo "legacy_version_file = yes" > $HOME/.asdfrc echo "legacy_version_file = yes" >$HOME/.asdfrc
run find_versions "dummy" $PROJECT_DIR run find_versions "dummy" $PROJECT_DIR
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -233,14 +233,14 @@ teardown() {
@test "get_preset_version_for returns the current version" { @test "get_preset_version_for returns the current version" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo "dummy 0.2.0" > .tool-versions echo "dummy 0.2.0" >.tool-versions
run get_preset_version_for "dummy" run get_preset_version_for "dummy"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "0.2.0" ] [ "$output" = "0.2.0" ]
} }
@test "get_preset_version_for returns the global version from home when project is outside of home" { @test "get_preset_version_for returns the global version from home when project is outside of home" {
echo "dummy 0.1.0" > $HOME/.tool-versions echo "dummy 0.1.0" >$HOME/.tool-versions
PROJECT_DIR=$BASE_DIR/project PROJECT_DIR=$BASE_DIR/project
mkdir -p $PROJECT_DIR mkdir -p $PROJECT_DIR
run get_preset_version_for "dummy" run get_preset_version_for "dummy"
@ -250,7 +250,7 @@ teardown() {
@test "get_preset_version_for returns the tool version from env if ASDF_{TOOL}_VERSION is defined" { @test "get_preset_version_for returns the tool version from env if ASDF_{TOOL}_VERSION is defined" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo "dummy 0.2.0" > .tool-versions echo "dummy 0.2.0" >.tool-versions
ASDF_DUMMY_VERSION=3.0.0 run get_preset_version_for "dummy" ASDF_DUMMY_VERSION=3.0.0 run get_preset_version_for "dummy"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "3.0.0" ] [ "$output" = "3.0.0" ]
@ -258,7 +258,7 @@ teardown() {
@test "get_preset_version_for should return branch reference version" { @test "get_preset_version_for should return branch reference version" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo "dummy ref:master" > $PROJECT_DIR/.tool-versions echo "dummy ref:master" >$PROJECT_DIR/.tool-versions
run get_preset_version_for "dummy" run get_preset_version_for "dummy"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "ref:master" ] [ "$output" = "ref:master" ]
@ -266,7 +266,7 @@ teardown() {
@test "get_preset_version_for should return path version" { @test "get_preset_version_for should return path version" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo "dummy path:/some/place with spaces" > $PROJECT_DIR/.tool-versions echo "dummy path:/some/place with spaces" >$PROJECT_DIR/.tool-versions
run get_preset_version_for "dummy" run get_preset_version_for "dummy"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "path:/some/place with spaces" ] [ "$output" = "path:/some/place with spaces" ]
@ -316,7 +316,7 @@ teardown() {
} }
@test "find_tool_versions will find a .tool-versions path if it exists in current directory" { @test "find_tool_versions will find a .tool-versions path if it exists in current directory" {
echo "dummy 0.1.0" > $PROJECT_DIR/.tool-versions echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
cd $PROJECT_DIR cd $PROJECT_DIR
run find_tool_versions run find_tool_versions
@ -325,7 +325,7 @@ teardown() {
} }
@test "find_tool_versions will find a .tool-versions path if it exists in parent directory" { @test "find_tool_versions will find a .tool-versions path if it exists in parent directory" {
echo "dummy 0.1.0" > $PROJECT_DIR/.tool-versions echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
mkdir -p $PROJECT_DIR/child mkdir -p $PROJECT_DIR/child
cd $PROJECT_DIR/child cd $PROJECT_DIR/child
@ -380,7 +380,7 @@ teardown() {
} }
@test "strip_tool_version_comments removes lines that only contain comments" { @test "strip_tool_version_comments removes lines that only contain comments" {
cat <<EOF > test_file cat <<EOF >test_file
# comment line # comment line
ruby 2.0.0 ruby 2.0.0
EOF EOF
@ -389,14 +389,14 @@ EOF
[ "$output" = "ruby 2.0.0" ] [ "$output" = "ruby 2.0.0" ]
} }
@test "strip_tool_version_comments removes lines that only contain comments even with missing newline" { @test "strip_tool_version_comments removes lines that only contain comments even with missing newline" {
echo -n "# comment line" > test_file echo -n "# comment line" >test_file
run strip_tool_version_comments test_file run strip_tool_version_comments test_file
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "" ] [ "$output" = "" ]
} }
@test "strip_tool_version_comments removes trailing comments on lines containing version information" { @test "strip_tool_version_comments removes trailing comments on lines containing version information" {
cat <<EOF > test_file cat <<EOF >test_file
ruby 2.0.0 # inline comment ruby 2.0.0 # inline comment
EOF EOF
run strip_tool_version_comments test_file run strip_tool_version_comments test_file
@ -405,23 +405,24 @@ EOF
} }
@test "strip_tool_version_comments removes trailing comments on lines containing version information even with missing newline" { @test "strip_tool_version_comments removes trailing comments on lines containing version information even with missing newline" {
echo -n "ruby 2.0.0 # inline comment" > test_file echo -n "ruby 2.0.0 # inline comment" >test_file
run strip_tool_version_comments test_file run strip_tool_version_comments test_file
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "ruby 2.0.0" ] [ "$output" = "ruby 2.0.0" ]
} }
@test "strip_tool_version_comments removes all comments from the version file" { @test "strip_tool_version_comments removes all comments from the version file" {
cat <<EOF > test_file cat <<EOF >test_file
ruby 2.0.0 # inline comment ruby 2.0.0 # inline comment
# comment line # comment line
erlang 18.2.1 # inline comment erlang 18.2.1 # inline comment
EOF EOF
expected="$(cat <<EOF expected="$(
cat <<EOF
ruby 2.0.0 ruby 2.0.0
erlang 18.2.1 erlang 18.2.1
EOF EOF
)" )"
run strip_tool_version_comments test_file run strip_tool_version_comments test_file
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" = "$expected" ] [ "$output" = "$expected" ]
@ -429,7 +430,7 @@ EOF
@test "with_shim_executable doesn't crash when executable names contain dashes" { @test "with_shim_executable doesn't crash when executable names contain dashes" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo "dummy 0.1.0" > $PROJECT_DIR/.tool-versions echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
mkdir -p $ASDF_DIR/installs/dummy/0.1.0/bin mkdir -p $ASDF_DIR/installs/dummy/0.1.0/bin
touch $ASDF_DIR/installs/dummy/0.1.0/bin/test-dash touch $ASDF_DIR/installs/dummy/0.1.0/bin/test-dash
chmod +x $ASDF_DIR/installs/dummy/0.1.0/bin/test-dash chmod +x $ASDF_DIR/installs/dummy/0.1.0/bin/test-dash

View File

@ -111,7 +111,7 @@ teardown() {
} }
@test "local should not create a duplicate .tool-versions file if such file exists" { @test "local should not create a duplicate .tool-versions file if such file exists" {
echo 'dummy 1.0.0' >> $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0' >>$PROJECT_DIR/.tool-versions
run asdf local "dummy" "1.1.0" run asdf local "dummy" "1.1.0"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -119,7 +119,7 @@ teardown() {
} }
@test "local should overwrite the existing version if it's set" { @test "local should overwrite the existing version if it's set" {
echo 'dummy 1.0.0' >> $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0' >>$PROJECT_DIR/.tool-versions
run asdf local "dummy" "1.1.0" run asdf local "dummy" "1.1.0"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -167,7 +167,7 @@ teardown() {
@test "local -p/--parent should overwrite the existing version if it's set" { @test "local -p/--parent should overwrite the existing version if it's set" {
cd $CHILD_DIR cd $CHILD_DIR
echo 'dummy 1.0.0' >> $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0' >>$PROJECT_DIR/.tool-versions
run asdf local -p "dummy" "1.1.0" run asdf local -p "dummy" "1.1.0"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy 1.1.0" ] [ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy 1.1.0" ]
@ -230,7 +230,7 @@ teardown() {
} }
@test "global should overwrite the existing version if it's set" { @test "global should overwrite the existing version if it's set" {
echo 'dummy 1.0.0' >> $HOME/.tool-versions echo 'dummy 1.0.0' >>$HOME/.tool-versions
run asdf global "dummy" "1.1.0" run asdf global "dummy" "1.1.0"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$(cat $HOME/.tool-versions)" = "dummy 1.1.0" ] [ "$(cat $HOME/.tool-versions)" = "dummy 1.1.0" ]
@ -260,7 +260,7 @@ teardown() {
@test "local should overwrite contents of ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" { @test "local should overwrite contents of ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" {
export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="local-tool-versions" export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="local-tool-versions"
echo 'dummy 1.0.0' >> "$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" echo 'dummy 1.0.0' >>"$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME"
run asdf local "dummy" "1.1.0" run asdf local "dummy" "1.1.0"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$(cat $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME)" = "dummy 1.1.0" ] [ "$(cat $ASDF_DEFAULT_TOOL_VERSIONS_FILENAME)" = "dummy 1.1.0" ]
@ -268,7 +268,6 @@ teardown() {
unset ASDF_DEFAULT_TOOL_VERSIONS_FILENAME unset ASDF_DEFAULT_TOOL_VERSIONS_FILENAME
} }
@test "global should write to ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" { @test "global should write to ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" {
export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="global-tool-versions" export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="global-tool-versions"
run asdf global "dummy" "1.1.0" run asdf global "dummy" "1.1.0"
@ -280,7 +279,7 @@ teardown() {
@test "global should overwrite contents of ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" { @test "global should overwrite contents of ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" {
export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="global-tool-versions" export ASDF_DEFAULT_TOOL_VERSIONS_FILENAME="global-tool-versions"
echo 'dummy 1.0.0' >> "$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" echo 'dummy 1.0.0' >>"$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME"
run asdf global "dummy" "1.1.0" run asdf global "dummy" "1.1.0"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$(cat $HOME/$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME)" = "dummy 1.1.0" ] [ "$(cat $HOME/$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME)" = "dummy 1.1.0" ]
@ -434,28 +433,28 @@ false"
} }
@test "[global - dummy_plugin] should support latest" { @test "[global - dummy_plugin] should support latest" {
echo 'dummy 1.0.0' >> $HOME/.tool-versions echo 'dummy 1.0.0' >>$HOME/.tool-versions
run asdf global "dummy" "1.0.0" "latest" run asdf global "dummy" "1.0.0" "latest"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$(cat $HOME/.tool-versions)" = "dummy 1.0.0 2.0.0" ] [ "$(cat $HOME/.tool-versions)" = "dummy 1.0.0 2.0.0" ]
} }
@test "[global - dummy_legcay_plugin] should support latest" { @test "[global - dummy_legcay_plugin] should support latest" {
echo 'legacy-dummy 1.0.0' >> $HOME/.tool-versions echo 'legacy-dummy 1.0.0' >>$HOME/.tool-versions
run asdf global "legacy-dummy" "1.0.0" "latest" run asdf global "legacy-dummy" "1.0.0" "latest"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$(cat $HOME/.tool-versions)" = "legacy-dummy 1.0.0 5.1.0" ] [ "$(cat $HOME/.tool-versions)" = "legacy-dummy 1.0.0 5.1.0" ]
} }
@test "[local - dummy_plugin] should support latest" { @test "[local - dummy_plugin] should support latest" {
echo 'dummy 1.0.0' >> $PROJECT_DIR/.tool-versions echo 'dummy 1.0.0' >>$PROJECT_DIR/.tool-versions
run asdf local "dummy" "1.0.0" "latest" run asdf local "dummy" "1.0.0" "latest"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy 1.0.0 2.0.0" ] [ "$(cat $PROJECT_DIR/.tool-versions)" = "dummy 1.0.0 2.0.0" ]
} }
@test "[local - dummy_legacy_plugin] should support latest" { @test "[local - dummy_legacy_plugin] should support latest" {
echo 'legacy-dummy 1.0.0' >> $PROJECT_DIR/.tool-versions echo 'legacy-dummy 1.0.0' >>$PROJECT_DIR/.tool-versions
run asdf local "legacy-dummy" "1.0.0" "latest" run asdf local "legacy-dummy" "1.0.0" "latest"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$(cat $PROJECT_DIR/.tool-versions)" = "legacy-dummy 1.0.0 5.1.0" ] [ "$(cat $PROJECT_DIR/.tool-versions)" = "legacy-dummy 1.0.0 5.1.0" ]

View File

@ -10,7 +10,7 @@ setup() {
PROJECT_DIR=$HOME/project PROJECT_DIR=$HOME/project
mkdir $PROJECT_DIR mkdir $PROJECT_DIR
echo 'dummy 1.0' >> $PROJECT_DIR/.tool-versions echo 'dummy 1.0' >>$PROJECT_DIR/.tool-versions
} }
teardown() { teardown() {
@ -36,7 +36,7 @@ teardown() {
@test "which should show dummy 1.0 other binary" { @test "which should show dummy 1.0 other binary" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo "echo bin bin/subdir" > "$ASDF_DIR/plugins/dummy/bin/list-bin-paths" echo "echo bin bin/subdir" >"$ASDF_DIR/plugins/dummy/bin/list-bin-paths"
chmod +x "$ASDF_DIR/plugins/dummy/bin/list-bin-paths" chmod +x "$ASDF_DIR/plugins/dummy/bin/list-bin-paths"
run asdf reshim dummy 1.0 run asdf reshim dummy 1.0
@ -46,7 +46,7 @@ teardown() {
} }
@test "which should show path of system version" { @test "which should show path of system version" {
echo 'dummy system' > $PROJECT_DIR/.tool-versions echo 'dummy system' >$PROJECT_DIR/.tool-versions
cd $PROJECT_DIR cd $PROJECT_DIR
mkdir $PROJECT_DIR/sys mkdir $PROJECT_DIR/sys
@ -59,7 +59,7 @@ teardown() {
} }
@test "which report when missing executable on system version" { @test "which report when missing executable on system version" {
echo 'dummy system' > $PROJECT_DIR/.tool-versions echo 'dummy system' >$PROJECT_DIR/.tool-versions
cd $PROJECT_DIR cd $PROJECT_DIR
run asdf which "dummy" run asdf which "dummy"
@ -87,10 +87,10 @@ teardown() {
@test "which should return the path set by the legacy file" { @test "which should return the path set by the legacy file" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo 'dummy 1.0' >> $HOME/.tool-versions echo 'dummy 1.0' >>$HOME/.tool-versions
echo '1.1' >> $PROJECT_DIR/.dummy-version echo '1.1' >>$PROJECT_DIR/.dummy-version
rm $PROJECT_DIR/.tool-versions rm $PROJECT_DIR/.tool-versions
echo 'legacy_version_file = yes' > $HOME/.asdfrc echo 'legacy_version_file = yes' >$HOME/.asdfrc
run asdf which "dummy" run asdf which "dummy"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
@ -99,7 +99,7 @@ teardown() {
@test "which should not return shim path" { @test "which should not return shim path" {
cd $PROJECT_DIR cd $PROJECT_DIR
echo 'dummy 1.0' > $PROJECT_DIR/.tool-versions echo 'dummy 1.0' >$PROJECT_DIR/.tool-versions
rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy" rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
run env PATH=$PATH:$ASDF_DIR/shims asdf which dummy run env PATH=$PATH:$ASDF_DIR/shims asdf which dummy