chore: Fix ShellCheck errors in tests (#1450)

This commit is contained in:
Edwin Kofler 2023-01-22 20:29:18 -08:00 committed by GitHub
parent b5e981cf1d
commit 28b348a041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 281 additions and 281 deletions

View File

@ -18,8 +18,8 @@ teardown() {
}
@test "current should derive from the current .tool-versions" {
cd $PROJECT_DIR
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'dummy 1.1.0' >>"$PROJECT_DIR/.tool-versions"
expected="dummy 1.1.0 $PROJECT_DIR/.tool-versions"
run asdf current "dummy"
@ -28,8 +28,8 @@ teardown() {
}
@test "current should handle long version name" {
cd $PROJECT_DIR
echo "dummy nightly-2000-01-01" >>$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo "dummy nightly-2000-01-01" >>"$PROJECT_DIR/.tool-versions"
expected="dummy nightly-2000-01-01 $PROJECT_DIR/.tool-versions"
run asdf current "dummy"
@ -38,8 +38,8 @@ teardown() {
}
@test "current should handle multiple versions" {
cd $PROJECT_DIR
echo "dummy 1.2.0 1.1.0" >>$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo "dummy 1.2.0 1.1.0" >>"$PROJECT_DIR/.tool-versions"
expected="dummy 1.2.0 1.1.0 $PROJECT_DIR/.tool-versions"
run asdf current "dummy"
@ -68,7 +68,7 @@ teardown() {
}
@test "current should error when no version is set" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
expected="dummy ______ No version is set. Run \"asdf <global|shell|local> dummy <version>\""
run asdf current "dummy"
@ -77,8 +77,8 @@ teardown() {
}
@test "current should error when a version is set that isn't installed" {
cd $PROJECT_DIR
echo 'dummy 9.9.9' >>$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'dummy 9.9.9' >>"$PROJECT_DIR/.tool-versions"
expected="dummy 9.9.9 Not installed. Run \"asdf install dummy 9.9.9\""
run asdf current "dummy"
@ -96,9 +96,9 @@ teardown() {
install_mock_plugin "baz"
cd $PROJECT_DIR
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
echo 'foobar 1.0.0' >>$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'dummy 1.1.0' >>"$PROJECT_DIR/.tool-versions"
echo 'foobar 1.0.0' >>"$PROJECT_DIR/.tool-versions"
run asdf current
expected="baz ______ No version is set. Run \"asdf <global|shell|local> baz <version>\"
@ -115,9 +115,9 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions"
install_mock_plugin "y"
install_mock_plugin_version "y" "2.1.0"
cd $PROJECT_DIR
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
echo 'y 2.1.0' >>$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'dummy 1.1.0' >>"$PROJECT_DIR/.tool-versions"
echo 'y 2.1.0' >>"$PROJECT_DIR/.tool-versions"
run asdf current "y"
[ "$status" -eq 0 ]

View File

@ -19,8 +19,8 @@ EOM
}
teardown() {
rm $ASDF_CONFIG_FILE
rm $ASDF_CONFIG_DEFAULT_FILE
rm "$ASDF_CONFIG_FILE"
rm "$ASDF_CONFIG_DEFAULT_FILE"
unset ASDF_CONFIG_DEFAULT_FILE
unset ASDF_CONFIG_FILE
}
@ -40,7 +40,7 @@ teardown() {
}
@test "get_config returns config file complete value including '=' symbols" {
cat >>$ASDF_CONFIG_FILE <<-'EOM'
cat >>"$ASDF_CONFIG_FILE" <<-'EOM'
key3 = VAR=val
EOM

View File

@ -18,7 +18,7 @@ teardown() {
}
@test "help should show dummy plugin help" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf help "dummy"
@ -34,7 +34,7 @@ EOF
}
@test "help should show dummy plugin help specific to version when version is present" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf help "dummy" "1.2.3"
@ -48,12 +48,12 @@ Details specific for version 1.2.3
EOF
)"
[ "$status" -eq 0 ]
echo $output
echo "$output"
[ "$output" = "$expected_output" ]
}
@test "help should fail for unknown plugins" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf help "sunny"
[ "$status" -eq 1 ]
@ -61,7 +61,7 @@ EOF
}
@test "help should fail when plugin doesn't have documentation callback" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf help "legacy-dummy"
[ "$status" -eq 1 ]
@ -69,7 +69,7 @@ EOF
}
@test "help should show asdf help when no plugin name is provided" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf help

View File

@ -18,7 +18,7 @@ teardown() {
}
@test "info should show os, shell and asdf debug information" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf info

View File

@ -29,7 +29,7 @@ teardown() {
}
@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"
run asdf install
[ "$status" -eq 0 ]
@ -37,7 +37,7 @@ teardown() {
}
@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"
run asdf install dummy
[ "$status" -eq 0 ]
@ -84,15 +84,15 @@ teardown() {
run asdf install dummy 1.1.0
[ "$status" -eq 0 ]
run grep "asdf-plugin: dummy 1.1.0" $ASDF_DIR/shims/dummy
run grep "asdf-plugin: dummy 1.1.0" "$ASDF_DIR/shims/dummy"
[ "$status" -eq 0 ]
run grep "asdf-plugin: dummy 1.0.0" $ASDF_DIR/shims/dummy
run grep "asdf-plugin: dummy 1.0.0" "$ASDF_DIR/shims/dummy"
[ "$status" -eq 1 ]
run asdf install dummy 1.0.0
[ "$status" -eq 0 ]
run grep "asdf-plugin: dummy 1.0.0" $ASDF_DIR/shims/dummy
run grep "asdf-plugin: dummy 1.0.0" "$ASDF_DIR/shims/dummy"
[ "$status" -eq 0 ]
run grep "# asdf-plugin: dummy 1.0.0"$'\n'"# asdf-plugin: dummy 1.1.0" "$ASDF_DIR/shims/dummy"
@ -103,8 +103,8 @@ teardown() {
}
@test "install_command without arguments should not generate shim for subdir" {
cd $PROJECT_DIR
echo 'dummy 1.0.0' >$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'dummy 1.0.0' >"$PROJECT_DIR/.tool-versions"
run asdf install
[ "$status" -eq 0 ]
@ -114,14 +114,14 @@ teardown() {
@test "install_command without arguments should generate shim that passes all arguments to executable" {
# 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/"
cd $PROJECT_DIR
echo 'dummy 1.0.0' >$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'dummy 1.0.0' >"$PROJECT_DIR/.tool-versions"
run asdf install
# execute the generated shim
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$status" -eq 0 ]
[ "$output" = "This is Dummy 1.0.0! hello world" ]
}
@ -134,8 +134,8 @@ teardown() {
}
@test "install_command fails if the plugin is not installed" {
cd $PROJECT_DIR
echo 'other_dummy 1.0.0' >$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'other_dummy 1.0.0' >"$PROJECT_DIR/.tool-versions"
run asdf install
[ "$status" -eq 1 ]
@ -143,8 +143,8 @@ teardown() {
}
@test "install_command fails if the plugin is not installed without collisions" {
cd $PROJECT_DIR
printf "dummy 1.0.0\ndum 1.0.0" >$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
printf "dummy 1.0.0\ndum 1.0.0" >"$PROJECT_DIR/.tool-versions"
run asdf install
[ "$status" -eq 1 ]
@ -152,7 +152,7 @@ teardown() {
}
@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
[ "$status" -eq 1 ]
[ "$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" {
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
[ "$status" -eq 1 ]
[ "$output" = "Dummy couldn't install version: other-dummy (on purpose)" ]
@ -170,12 +170,12 @@ teardown() {
@test "install_command without arguments uses a parent directory .tool-versions file if present" {
# 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
mkdir -p $PROJECT_DIR/child
echo 'dummy 1.0.0' >"$PROJECT_DIR/.tool-versions"
mkdir -p "$PROJECT_DIR/child"
cd $PROJECT_DIR/child
cd "$PROJECT_DIR/child"
run asdf install
@ -185,11 +185,11 @@ teardown() {
}
@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
cd $PROJECT_DIR
echo 'dummy 1.0.0 1.2.0' >"$PROJECT_DIR/.tool-versions"
cd "$PROJECT_DIR"
run asdf install
echo $output
echo "$output"
[ "$status" -eq 0 ]
[ "$(cat "$ASDF_DIR/installs/dummy/1.0.0/version")" = "1.0.0" ]
@ -203,7 +203,7 @@ teardown() {
}
@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
EOM
@ -212,7 +212,7 @@ EOM
}
@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
EOM
@ -234,8 +234,8 @@ EOM
echo 'legacy_version_file = yes' >"$HOME/.asdfrc"
echo '1.2.0' >>"$PROJECT_DIR/.dummy-version"
mkdir -p $PROJECT_DIR/child
cd $PROJECT_DIR/child
mkdir -p "$PROJECT_DIR/child"
cd "$PROJECT_DIR/child"
run asdf install
[ "$status" -eq 0 ]
@ -272,7 +272,7 @@ EOM
@test "install_command keeps the download directory when always_keep_download setting is true" {
echo 'always_keep_download = yes' >"$HOME/.asdfrc"
run asdf install dummy 1.1.0
echo $output
echo "$output"
[ "$status" -eq 0 ]
[ -d "$ASDF_DIR/downloads/dummy/1.1.0" ]
[ "$(cat "$ASDF_DIR/installs/dummy/1.1.0/version")" = "1.1.0" ]
@ -280,7 +280,7 @@ EOM
@test "install_command fails when download script exits with non-zero code" {
run asdf install dummy-broken 1.0.0
echo $output
echo "$output"
[ "$status" -eq 1 ]
[ ! -d "$ASDF_DIR/downloads/dummy-broken/1.1.0" ]
[ ! -d "$ASDF_DIR/installs/dummy-broken/1.1.0" ]

View File

@ -25,8 +25,8 @@ teardown() {
}
@test "list_command should list plugins with installed versions and any selected versions marked with asterisk" {
cd $PROJECT_DIR
echo 'dummy 1.1.0' >>$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'dummy 1.1.0' >>"$PROJECT_DIR/.tool-versions"
run asdf install dummy 1.0.0
run asdf install dummy 1.1.0
@ -95,14 +95,14 @@ teardown() {
@test "list_all_command fails when list-all script exits with non-zero code" {
run asdf list-all dummy-broken
echo $output
echo "$output"
[ "$status" -eq 1 ]
[[ "$output" == "Plugin dummy-broken's list-all callback script failed with output:"* ]]
}
@test "list_all_command displays stderr then stdout when failing" {
run asdf list-all dummy-broken
echo $output
echo "$output"
[[ "$output" == *"List-all failed!"* ]]
[[ "$output" == *"Attempting to list versions" ]]
}

View File

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

View File

@ -29,7 +29,7 @@ teardown() {
}
@test "asdf help shows extension commands for plugin with hyphens in the name" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
plugin_name=dummy-hyphenated
install_mock_plugin $plugin_name

View File

@ -157,7 +157,7 @@ teardown() {
}
@test "asdf plugin-update executes configured pre hook (generic)" {
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
pre_asdf_plugin_update = echo UPDATE ${@}
EOM
@ -173,7 +173,7 @@ EOM
}
@test "asdf plugin-update executes configured pre hook (specific)" {
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
pre_asdf_plugin_update_dummy = echo UPDATE
EOM
@ -189,7 +189,7 @@ EOM
}
@test "asdf plugin-update executes configured post hook (generic)" {
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
post_asdf_plugin_update = echo UPDATE ${@}
EOM
@ -206,7 +206,7 @@ UPDATE dummy"
}
@test "asdf plugin-update executes configured post hook (specific)" {
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
post_asdf_plugin_update_dummy = echo UPDATE
EOM

View File

@ -77,7 +77,7 @@ teardown() {
@test "plugin_remove_command executes configured pre hook (generic)" {
install_dummy_plugin
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
pre_asdf_plugin_remove = echo REMOVE ${@}
EOM
@ -91,7 +91,7 @@ plugin-remove ${ASDF_DIR}/plugins/dummy"
@test "plugin_remove_command executes configured pre hook (specific)" {
install_dummy_plugin
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
pre_asdf_plugin_remove_dummy = echo REMOVE
EOM
@ -105,7 +105,7 @@ plugin-remove ${ASDF_DIR}/plugins/dummy"
@test "plugin_remove_command executes configured post hook (generic)" {
install_dummy_plugin
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
post_asdf_plugin_remove = echo REMOVE ${@}
EOM
@ -119,7 +119,7 @@ REMOVE dummy"
@test "plugin_remove_command executes configured post hook (specific)" {
install_dummy_plugin
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
post_asdf_plugin_remove_dummy = echo REMOVE
EOM

View File

@ -11,7 +11,7 @@ setup() {
cd "$PROJECT_DIR"
# 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/"
}
teardown() {
@ -25,7 +25,7 @@ teardown() {
}
@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 env dummy which dummy
@ -34,7 +34,7 @@ teardown() {
}
@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
echo "export FOO=bar" >"$ASDF_DIR/plugins/dummy/bin/exec-env"
@ -46,13 +46,13 @@ teardown() {
}
@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
echo "export FOO=bar" >"$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
[ "$status" -eq 0 ]
@ -67,7 +67,7 @@ teardown() {
}
@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 env dummy

View File

@ -11,7 +11,7 @@ setup() {
cd "$PROJECT_DIR"
# 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/"
}
teardown() {
@ -25,7 +25,7 @@ teardown() {
}
@test "asdf exec should pass all arguments to executable" {
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
run asdf install
run asdf exec dummy world hello
@ -34,7 +34,7 @@ teardown() {
}
@test "asdf exec should pass all arguments to executable even if shim is not in PATH" {
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
run asdf install
path=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g")
@ -48,16 +48,16 @@ teardown() {
}
@test "shim exec should pass all arguments to executable" {
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
run asdf install
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$output" = "This is Dummy 1.0! hello world" ]
[ "$status" -eq 0 ]
}
@test "shim exec should pass stdin to executable" {
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
run asdf install
echo "tr [:lower:] [:upper:]" >"$ASDF_DIR/installs/dummy/1.0/bin/upper"
@ -73,9 +73,9 @@ teardown() {
@test "shim exec should fail if no version is selected" {
run asdf install dummy 1.0
touch $PROJECT_DIR/.tool-versions
touch "$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$status" -eq 126 ]
echo "$output" | grep -q "No version is set for command dummy" 2>/dev/null
}
@ -84,9 +84,9 @@ teardown() {
run asdf install dummy 1.0
run asdf install dummy 2.0.0
touch $PROJECT_DIR/.tool-versions
touch "$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$status" -eq 126 ]
echo "$output" | grep -q "No version is set for command dummy" 2>/dev/null
@ -97,14 +97,14 @@ teardown() {
@test "shim exec should suggest different plugins providing same tool when no version is selected" {
# Another fake plugin with 'dummy' executable
cp -rf $ASDF_DIR/plugins/dummy $ASDF_DIR/plugins/mummy
cp -rf "$ASDF_DIR/plugins/dummy" "$ASDF_DIR/plugins/mummy"
run asdf install dummy 1.0
run asdf install mummy 3.0
touch $PROJECT_DIR/.tool-versions
touch "$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$status" -eq 126 ]
echo "$output" | grep -q "No version is set for command dummy" 2>/dev/null
@ -116,9 +116,9 @@ teardown() {
@test "shim exec should suggest to install missing version" {
run asdf install dummy 1.0
echo "dummy 2.0.0 1.3" >$PROJECT_DIR/.tool-versions
echo "dummy 2.0.0 1.3" >"$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$status" -eq 126 ]
echo "$output" | grep -q "No preset version installed for command dummy" 2>/dev/null
echo "$output" | grep -q "Please install a version by running one of the following:" 2>/dev/null
@ -132,9 +132,9 @@ teardown() {
run asdf install dummy 2.0.0
run asdf install dummy 3.0
echo "dummy 1.0 3.0 2.0.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0 3.0 2.0.0" >"$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$status" -eq 0 ]
echo "$output" | grep -q "This is Dummy 3.0! hello world" 2>/dev/null
@ -143,10 +143,10 @@ teardown() {
@test "shim exec should only use the first version found for a plugin" {
run asdf install dummy 3.0
echo "dummy 3.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >>$PROJECT_DIR/.tool-versions
echo "dummy 3.0" >"$PROJECT_DIR/.tool-versions"
echo "dummy 1.0" >>"$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$status" -eq 0 ]
echo "$output" | grep -q "This is Dummy 3.0! hello world" 2>/dev/null
@ -154,40 +154,40 @@ teardown() {
@test "shim exec should determine correct executable on two projects using different plugins that provide the same tool" {
# Another fake plugin with 'dummy' executable
cp -rf $ASDF_DIR/plugins/dummy $ASDF_DIR/plugins/mummy
sed -i -e 's/Dummy/Mummy/' $ASDF_DIR/plugins/mummy/bin/install
cp -rf "$ASDF_DIR/plugins/dummy" "$ASDF_DIR/plugins/mummy"
sed -i -e 's/Dummy/Mummy/' "$ASDF_DIR/plugins/mummy/bin/install"
run asdf install mummy 3.0
run asdf install dummy 1.0
mkdir $PROJECT_DIR/{A,B}
echo "dummy 1.0" >$PROJECT_DIR/A/.tool-versions
echo "mummy 3.0" >$PROJECT_DIR/B/.tool-versions
mkdir "$PROJECT_DIR"/{A,B}
echo "dummy 1.0" >"$PROJECT_DIR/A/.tool-versions"
echo "mummy 3.0" >"$PROJECT_DIR/B/.tool-versions"
cd $PROJECT_DIR/A
run $ASDF_DIR/shims/dummy world hello
cd "$PROJECT_DIR"/A
run "$ASDF_DIR/shims/dummy" world hello
[ "$output" = "This is Dummy 1.0! hello world" ]
[ "$status" -eq 0 ]
cd $PROJECT_DIR/B
run $ASDF_DIR/shims/dummy world hello
cd "$PROJECT_DIR"/B
run "$ASDF_DIR/shims/dummy" world hello
[ "$output" = "This is Mummy 3.0! hello world" ]
[ "$status" -eq 0 ]
}
@test "shim exec should determine correct executable on a project with two plugins set that provide the same tool" {
# Another fake plugin with 'dummy' executable
cp -rf $ASDF_DIR/plugins/dummy $ASDF_DIR/plugins/mummy
sed -i -e 's/Dummy/Mummy/' $ASDF_DIR/plugins/mummy/bin/install
cp -rf "$ASDF_DIR/plugins/dummy" "$ASDF_DIR/plugins/mummy"
sed -i -e 's/Dummy/Mummy/' "$ASDF_DIR/plugins/mummy/bin/install"
run asdf install dummy 1.0
run asdf install mummy 3.0
echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions
echo "mummy 3.0" >>$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >>$PROJECT_DIR/.tool-versions
echo "dummy 2.0.0" >"$PROJECT_DIR/.tool-versions"
echo "mummy 3.0" >>"$PROJECT_DIR/.tool-versions"
echo "dummy 1.0" >>"$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$output" = "This is Mummy 3.0! hello world" ]
[ "$status" -eq 0 ]
}
@ -195,11 +195,11 @@ teardown() {
@test "shim exec should fallback to system executable when specified version is system" {
run asdf install dummy 1.0
echo "dummy system" >$PROJECT_DIR/.tool-versions
echo "dummy system" >"$PROJECT_DIR/.tool-versions"
mkdir $PROJECT_DIR/foo/
echo "echo System" >$PROJECT_DIR/foo/dummy
chmod +x $PROJECT_DIR/foo/dummy
mkdir "$PROJECT_DIR/foo/"
echo "echo System" >"$PROJECT_DIR/foo/dummy"
chmod +x "$PROJECT_DIR/foo/dummy"
run env "PATH=$PATH:$PROJECT_DIR/foo" "$ASDF_DIR/shims/dummy" hello
[ "$output" = "System" ]
@ -214,21 +214,21 @@ teardown() {
echo "echo System" >"$CUSTOM_DUMMY_BIN_PATH/dummy"
chmod +x "$CUSTOM_DUMMY_BIN_PATH/dummy"
echo "dummy path:$CUSTOM_DUMMY_PATH" >$PROJECT_DIR/.tool-versions
echo "dummy path:$CUSTOM_DUMMY_PATH" >"$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy hello
run "$ASDF_DIR/shims/dummy" hello
[ "$output" = "System" ]
}
@test "shim exec should execute system if set first" {
run asdf install dummy 2.0.0
echo "dummy system" >$PROJECT_DIR/.tool-versions
echo "dummy 2.0.0" >>$PROJECT_DIR/.tool-versions
echo "dummy system" >"$PROJECT_DIR/.tool-versions"
echo "dummy 2.0.0" >>"$PROJECT_DIR/.tool-versions"
mkdir $PROJECT_DIR/foo/
echo "echo System" >$PROJECT_DIR/foo/dummy
chmod +x $PROJECT_DIR/foo/dummy
mkdir "$PROJECT_DIR/foo/"
echo "echo System" >"$PROJECT_DIR/foo/dummy"
chmod +x "$PROJECT_DIR/foo/dummy"
run env "PATH=$PATH:$PROJECT_DIR/foo" "$ASDF_DIR/shims/dummy" hello
[ "$output" = "System" ]
@ -242,8 +242,8 @@ teardown() {
chmod +x "$ASDF_DIR/plugins/dummy/shims/foo"
run asdf reshim dummy 2.0.0
echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/foo
echo "dummy 2.0.0" >"$PROJECT_DIR/.tool-versions"
run "$ASDF_DIR/shims/foo"
[ "$output" = "sourced custom" ]
}
@ -255,8 +255,8 @@ teardown() {
chmod +x "$ASDF_DIR/plugins/dummy/shims/foo"
run asdf reshim dummy 2.0.0
echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/foo
echo "dummy 2.0.0" >"$PROJECT_DIR/.tool-versions"
run "$ASDF_DIR/shims/foo"
[ "$output" = "$ASDF_DIR/installs/dummy/2.0.0/foo custom" ]
}
@ -268,11 +268,11 @@ teardown() {
chmod +x "$ASDF_DIR/plugins/dummy/shims/foo"
run asdf reshim dummy 2.0.0
echo "dummy system" >$PROJECT_DIR/.tool-versions
echo "dummy system" >"$PROJECT_DIR/.tool-versions"
mkdir $PROJECT_DIR/sys/
echo 'echo x$FOO System' >$PROJECT_DIR/sys/foo
chmod +x $PROJECT_DIR/sys/foo
mkdir "$PROJECT_DIR/sys/"
echo 'echo x$FOO System' >"$PROJECT_DIR/sys/foo"
chmod +x "$PROJECT_DIR/sys/foo"
run env "PATH=$PATH:$PROJECT_DIR/sys" "$ASDF_DIR/shims/foo"
[ "$output" = "x System" ]
@ -281,53 +281,53 @@ teardown() {
@test "shim exec should prepend the plugin paths on execution" {
run asdf install dummy 2.0.0
mkdir $ASDF_DIR/plugins/dummy/shims
echo 'which dummy' >$ASDF_DIR/plugins/dummy/shims/foo
chmod +x $ASDF_DIR/plugins/dummy/shims/foo
mkdir "$ASDF_DIR/plugins/dummy/shims"
echo 'which dummy' >"$ASDF_DIR/plugins/dummy/shims/foo"
chmod +x "$ASDF_DIR/plugins/dummy/shims/foo"
run asdf reshim dummy 2.0.0
echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions
echo "dummy 2.0.0" >"$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/foo
run "$ASDF_DIR/shims/foo"
[ "$output" = "$ASDF_DIR/installs/dummy/2.0.0/bin/dummy" ]
}
@test "shim exec should be able to find other shims in path" {
cp -rf $ASDF_DIR/plugins/dummy $ASDF_DIR/plugins/gummy
cp -rf "$ASDF_DIR/plugins/dummy" "$ASDF_DIR/plugins/gummy"
echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions
echo "gummy 2.0.0" >>$PROJECT_DIR/.tool-versions
echo "dummy 2.0.0" >"$PROJECT_DIR/.tool-versions"
echo "gummy 2.0.0" >>"$PROJECT_DIR/.tool-versions"
run asdf install
mkdir $ASDF_DIR/plugins/{dummy,gummy}/shims
mkdir "$ASDF_DIR/plugins/"{dummy,gummy}/shims
echo 'which dummy' >$ASDF_DIR/plugins/dummy/shims/foo
chmod +x $ASDF_DIR/plugins/dummy/shims/foo
echo 'which dummy' >"$ASDF_DIR/plugins/dummy/shims/foo"
chmod +x "$ASDF_DIR/plugins/dummy/shims/foo"
echo 'which gummy' >$ASDF_DIR/plugins/dummy/shims/bar
chmod +x $ASDF_DIR/plugins/dummy/shims/bar
echo 'which gummy' >"$ASDF_DIR/plugins/dummy/shims/bar"
chmod +x "$ASDF_DIR/plugins/dummy/shims/bar"
touch $ASDF_DIR/plugins/gummy/shims/gummy
chmod +x $ASDF_DIR/plugins/gummy/shims/gummy
touch "$ASDF_DIR/plugins/gummy/shims/gummy"
chmod +x "$ASDF_DIR/plugins/gummy/shims/gummy"
run asdf reshim
run $ASDF_DIR/shims/foo
run "$ASDF_DIR/shims/foo"
[ "$output" = "$ASDF_DIR/installs/dummy/2.0.0/bin/dummy" ]
run $ASDF_DIR/shims/bar
run "$ASDF_DIR/shims/bar"
[ "$output" = "$ASDF_DIR/shims/gummy" ]
}
@test "shim exec should remove shim_path from path on system version execution" {
run asdf install dummy 2.0.0
echo "dummy system" >$PROJECT_DIR/.tool-versions
echo "dummy system" >"$PROJECT_DIR/.tool-versions"
mkdir $PROJECT_DIR/sys/
echo 'which dummy' >$PROJECT_DIR/sys/dummy
chmod +x $PROJECT_DIR/sys/dummy
mkdir "$PROJECT_DIR/sys/"
echo 'which dummy' >"$PROJECT_DIR/sys/dummy"
chmod +x "$PROJECT_DIR/sys/dummy"
run env "PATH=$PATH:$PROJECT_DIR/sys" "$ASDF_DIR/shims/dummy"
echo "$status $output"
@ -340,7 +340,7 @@ teardown() {
echo "legacy_version_file = yes" >"$HOME/.asdfrc"
echo "2.0.0" >"$PROJECT_DIR/.dummy-version"
run $ASDF_DIR/shims/dummy world hello
run "$ASDF_DIR/shims/dummy" world hello
[ "$output" = "This is Dummy 2.0.0! hello world" ]
}
@ -354,19 +354,19 @@ teardown() {
exec_path="$ASDF_DIR/plugins/dummy/bin/list-bin-paths"
custom_path="$ASDF_DIR/installs/dummy/1.0/custom"
echo "echo bin custom" >$exec_path
chmod +x $exec_path
echo "echo bin custom" >"$exec_path"
chmod +x "$exec_path"
run asdf install dummy 1.0
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
mkdir $custom_path
echo "echo CUSTOM" >$custom_path/foo
chmod +x $custom_path/foo
mkdir "$custom_path"
echo "echo CUSTOM" >"$custom_path/foo"
chmod +x "$custom_path/foo"
run asdf reshim dummy 1.0
run $ASDF_DIR/shims/foo
run "$ASDF_DIR/shims/foo"
[ "$output" = "CUSTOM" ]
}
@ -376,16 +376,16 @@ teardown() {
exec_path="$ASDF_DIR/plugins/dummy/bin/exec-path"
custom_dummy="$ASDF_DIR/installs/dummy/1.0/custom/dummy"
echo "echo custom/dummy" >$exec_path
chmod +x $exec_path
echo "echo custom/dummy" >"$exec_path"
chmod +x "$exec_path"
mkdir "$(dirname "$custom_dummy")"
echo "echo CUSTOM" >"$custom_dummy"
chmod +x "$custom_dummy"
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy
run "$ASDF_DIR/shims/dummy"
[ "$output" = "CUSTOM" ]
}
@ -397,21 +397,21 @@ teardown() {
echo 'echo $3 # always same path' >"$exec_path"
chmod +x "$exec_path"
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
run $ASDF_DIR/shims/dummy
run "$ASDF_DIR/shims/dummy"
[ "$output" = "This is Dummy 1.0!" ]
}
@test "shim exec executes configured pre-hook" {
run asdf install dummy 1.0
echo dummy 1.0 >$PROJECT_DIR/.tool-versions
echo dummy 1.0 >"$PROJECT_DIR/.tool-versions"
cat >$HOME/.asdfrc <<-'EOM'
cat >"$HOME/.asdfrc" <<-'EOM'
pre_dummy_dummy = echo PRE $version $1 $2
EOM
run $ASDF_DIR/shims/dummy hello world
run "$ASDF_DIR/shims/dummy" hello world
[ "$status" -eq 0 ]
echo "$output" | grep "PRE 1.0 hello world"
echo "$output" | grep "This is Dummy 1.0! world hello"
@ -419,14 +419,14 @@ EOM
@test "shim exec doesnt execute command if pre-hook failed" {
run asdf install dummy 1.0
echo dummy 1.0 >$PROJECT_DIR/.tool-versions
echo dummy 1.0 >"$PROJECT_DIR/.tool-versions"
mkdir $HOME/hook
mkdir "$HOME/hook"
pre_cmd="$HOME/hook/pre"
echo 'echo $* && false' >"$pre_cmd"
chmod +x "$pre_cmd"
cat >$HOME/.asdfrc <<'EOM'
cat >"$HOME/.asdfrc" <<'EOM'
pre_dummy_dummy = pre $1 no $plugin_name $2
EOM
@ -439,11 +439,11 @@ EOM
@test "asdf exec should not crash when POSIXLY_CORRECT=1" {
export POSIXLY_CORRECT=1
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
echo "dummy 1.0" >"$PROJECT_DIR/.tool-versions"
run asdf install
run asdf exec dummy world hello
echo $output
echo "$output"
[ "$output" = "This is Dummy 1.0! hello world" ]
[ "$status" -eq 0 ]
}

View File

@ -16,7 +16,7 @@ teardown() {
}
@test "shim_versions_command should list plugins and versions where command is available" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf install dummy 3.0
run asdf install dummy 1.0
run asdf reshim dummy

View File

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

View File

@ -60,14 +60,14 @@ teardown() {
}
@test "asdf update is a noop for when updates are disabled" {
touch $ASDF_DIR/asdf_updates_disabled
touch "$ASDF_DIR/asdf_updates_disabled"
run asdf update
[ "$status" -eq 42 ]
[ "$(echo -e "Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.")" = "$output" ]
}
@test "asdf update is a noop for non-git repos" {
rm -rf $ASDF_DIR/.git/
rm -rf "$ASDF_DIR/.git/"
run asdf update
[ "$status" -eq 42 ]
[ "$(echo -e "Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.")" = "$output" ]

View File

@ -11,7 +11,7 @@ setup() {
PROJECT_DIR="$HOME/project"
mkdir -p "$PROJECT_DIR"
cd $HOME
cd "$HOME"
}
teardown() {
@ -42,7 +42,7 @@ teardown() {
run get_download_path foo version "1.0.0"
[ "$status" -eq 0 ]
download_path=${output#$HOME/}
echo $download_path
echo "$download_path"
[ "$download_path" = ".asdf/downloads/foo/1.0.0" ]
}
@ -83,15 +83,15 @@ teardown() {
}
@test "check_if_version_exists should be noop if version is system" {
mkdir -p $ASDF_DIR/plugins/foo
mkdir -p "$ASDF_DIR/plugins/foo"
run check_if_version_exists "foo" "system"
[ "$status" -eq 0 ]
[ "$output" = "" ]
}
@test "check_if_version_exists should be ok for ref:version install" {
mkdir -p $ASDF_DIR/plugins/foo
mkdir -p $ASDF_DIR/installs/foo/ref-master
mkdir -p "$ASDF_DIR/plugins/foo"
mkdir -p "$ASDF_DIR/installs/foo/ref-master"
run check_if_version_exists "foo" "ref:master"
[ "$status" -eq 0 ]
[ "$output" = "" ]
@ -110,8 +110,8 @@ teardown() {
}
@test "parse_asdf_version_file should output version" {
echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy
echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions"
run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy
[ "$status" -eq 0 ]
[ "$output" = "0.1.0" ]
}
@ -119,7 +119,7 @@ teardown() {
@test "parse_asdf_version_file should output path on project with spaces" {
PROJECT_DIR="$PROJECT_DIR/outer space"
mkdir -p "$PROJECT_DIR"
cd $outer
echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions"
run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy
[ "$status" -eq 0 ]
@ -127,24 +127,24 @@ teardown() {
}
@test "parse_asdf_version_file should output path version with spaces" {
echo "dummy path:/some/dummy path" >$PROJECT_DIR/.tool-versions
run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy
echo "dummy path:/some/dummy path" >"$PROJECT_DIR/.tool-versions"
run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy
[ "$status" -eq 0 ]
[ "$output" = "path:/some/dummy path" ]
}
@test "parse_asdf_version_file should output path version with tilda" {
echo "dummy path:~/some/dummy path" >$PROJECT_DIR/.tool-versions
run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy
echo "dummy path:~/some/dummy path" >"$PROJECT_DIR/.tool-versions"
run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy
[ "$status" -eq 0 ]
[ "$output" = "path:$HOME/some/dummy path" ]
}
@test "find_versions should return .tool-versions if legacy is disabled" {
echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
echo "0.2.0" >$PROJECT_DIR/.dummy-version
echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions"
echo "0.2.0" >"$PROJECT_DIR/.dummy-version"
run find_versions "dummy" $PROJECT_DIR
run find_versions "dummy" "$PROJECT_DIR"
[ "$status" -eq 0 ]
[ "$output" = "0.1.0|$PROJECT_DIR/.tool-versions" ]
}
@ -154,16 +154,16 @@ teardown() {
echo "dummy 0.1.0" >"$HOME/.tool-versions"
echo "0.2.0" >"$PROJECT_DIR/.dummy-version"
run find_versions "dummy" $PROJECT_DIR
run find_versions "dummy" "$PROJECT_DIR"
[ "$status" -eq 0 ]
[ "$output" = "0.2.0|$PROJECT_DIR/.dummy-version" ]
}
@test "find_versions skips .tool-version file that don't list the plugin" {
echo "dummy 0.1.0" >$HOME/.tool-versions
echo "another_plugin 0.3.0" >$PROJECT_DIR/.tool-versions
echo "dummy 0.1.0" >"$HOME/.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 ]
[ "$output" = "0.1.0|$HOME/.tool-versions" ]
}
@ -174,7 +174,7 @@ teardown() {
echo "legacy_version_file = yes" >"$HOME/.asdfrc"
rm "$ASDF_DIR/plugins/dummy/bin/list-legacy-filenames"
run find_versions "dummy" $PROJECT_DIR
run find_versions "dummy" "$PROJECT_DIR"
[ "$status" -eq 0 ]
[ "$output" = "0.1.0|$HOME/.tool-versions" ]
}
@ -182,9 +182,9 @@ teardown() {
@test "find_versions should return the version set by environment variable" {
export ASDF_DUMMY_VERSION=0.2.0
run find_versions "dummy" $PROJECT_DIR
run find_versions "dummy" "$PROJECT_DIR"
[ "$status" -eq 0 ]
echo $output
echo "$output"
[ "$output" = "0.2.0|ASDF_DUMMY_VERSION environment variable" ]
}
@ -220,9 +220,9 @@ teardown() {
@test "find_versions should return \$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME if set" {
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 ]
[ "$output" = "0.1.0|$ASDF_DEFAULT_TOOL_VERSIONS_FILENAME" ]
}
@ -233,13 +233,13 @@ teardown() {
echo "dummy 0.1.0" >"$HOME/.dummy-version"
echo "legacy_version_file = yes" >"$HOME/.asdfrc"
run find_versions "dummy" $PROJECT_DIR
run find_versions "dummy" "$PROJECT_DIR"
[ "$status" -eq 0 ]
[[ "$output" =~ "0.1.0|$HOME/.dummy-version" ]]
}
@test "get_preset_version_for returns the current version" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
echo "dummy 0.2.0" >.tool-versions
run get_preset_version_for "dummy"
[ "$status" -eq 0 ]
@ -247,16 +247,16 @@ teardown() {
}
@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
mkdir -p $PROJECT_DIR
mkdir -p "$PROJECT_DIR"
run get_preset_version_for "dummy"
[ "$status" -eq 0 ]
[ "$output" = "0.1.0" ]
}
@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
ASDF_DUMMY_VERSION=3.0.0 run get_preset_version_for "dummy"
[ "$status" -eq 0 ]
@ -264,40 +264,40 @@ teardown() {
}
@test "get_preset_version_for should return branch reference version" {
cd $PROJECT_DIR
echo "dummy ref:master" >$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo "dummy ref:master" >"$PROJECT_DIR/.tool-versions"
run get_preset_version_for "dummy"
[ "$status" -eq 0 ]
[ "$output" = "ref:master" ]
}
@test "get_preset_version_for should return path version" {
cd $PROJECT_DIR
echo "dummy path:/some/place with spaces" >$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo "dummy path:/some/place with spaces" >"$PROJECT_DIR/.tool-versions"
run get_preset_version_for "dummy"
[ "$status" -eq 0 ]
[ "$output" = "path:/some/place with spaces" ]
}
@test "get_preset_version_for should return path version with tilda" {
cd $PROJECT_DIR
echo "dummy path:~/some/place with spaces" >$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo "dummy path:~/some/place with spaces" >"$PROJECT_DIR/.tool-versions"
run get_preset_version_for "dummy"
[ "$status" -eq 0 ]
[ "$output" = "path:$HOME/some/place with spaces" ]
}
@test "get_executable_path for system version should return system path" {
mkdir -p $ASDF_DIR/plugins/foo
mkdir -p "$ASDF_DIR/plugins/foo"
run get_executable_path "foo" "system" "ls"
[ "$status" -eq 0 ]
[ "$output" = "$(which ls)" ]
}
@test "get_executable_path for system version should not use asdf shims" {
mkdir -p $ASDF_DIR/plugins/foo
touch $ASDF_DIR/shims/dummy_executable
chmod +x $ASDF_DIR/shims/dummy_executable
mkdir -p "$ASDF_DIR/plugins/foo"
touch "$ASDF_DIR/shims/dummy_executable"
chmod +x "$ASDF_DIR/shims/dummy_executable"
run which dummy_executable
[ "$status" -eq 0 ]
@ -331,8 +331,8 @@ teardown() {
}
@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
cd $PROJECT_DIR
echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions"
cd "$PROJECT_DIR"
run find_tool_versions
[ "$status" -eq 0 ]
@ -340,9 +340,9 @@ teardown() {
}
@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
mkdir -p $PROJECT_DIR/child
cd $PROJECT_DIR/child
echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions"
mkdir -p "$PROJECT_DIR/child"
cd "$PROJECT_DIR"/child
run find_tool_versions
[ "$status" -eq 0 ]
@ -366,7 +366,7 @@ teardown() {
@test "resolve_symlink converts the symlink path to the real file path" {
touch foo
ln -s $PWD/foo bar
ln -s "$PWD/foo" bar
run resolve_symlink bar
[ "$status" -eq 0 ]
@ -444,17 +444,17 @@ EOF
}
@test "with_shim_executable doesn't crash when executable names contain dashes" {
cd $PROJECT_DIR
echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
mkdir -p $ASDF_DIR/installs/dummy/0.1.0/bin
touch $ASDF_DIR/installs/dummy/0.1.0/bin/test-dash
chmod +x $ASDF_DIR/installs/dummy/0.1.0/bin/test-dash
cd "$PROJECT_DIR"
echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions"
mkdir -p "$ASDF_DIR/installs/dummy/0.1.0/bin"
touch "$ASDF_DIR/installs/dummy/0.1.0/bin/test-dash"
chmod +x "$ASDF_DIR/installs/dummy/0.1.0/bin/test-dash"
run asdf reshim dummy 0.1.0
message="callback invoked"
function callback() {
echo $message
echo "$message"
}
run with_shim_executable test-dash callback

View File

@ -21,10 +21,10 @@ setup() {
CHILD_DIR="$PROJECT_DIR/child-dir"
mkdir -p "$CHILD_DIR"
cd $PROJECT_DIR
cd "$PROJECT_DIR"
# asdf lib needed to run asdf.sh
cp -rf $BATS_TEST_DIRNAME/../{bin,lib} $ASDF_DIR/
cp -rf "$BATS_TEST_DIRNAME"/../{bin,lib} "$ASDF_DIR/"
}
teardown() {
@ -111,7 +111,7 @@ teardown() {
}
@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"
[ "$status" -eq 0 ]
@ -119,7 +119,7 @@ teardown() {
}
@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"
[ "$status" -eq 0 ]
@ -127,7 +127,7 @@ teardown() {
}
@test "local should append trailing newline before appending new version when missing" {
echo -n 'foobar 1.0.0' >>$PROJECT_DIR/.tool-versions
echo -n 'foobar 1.0.0' >>"$PROJECT_DIR/.tool-versions"
run asdf local "dummy" "1.1.0"
[ "$status" -eq 0 ]
@ -135,7 +135,7 @@ teardown() {
}
@test "local should not append trailing newline before appending new version when one present" {
echo 'foobar 1.0.0' >>$PROJECT_DIR/.tool-versions
echo 'foobar 1.0.0' >>"$PROJECT_DIR/.tool-versions"
run asdf local "dummy" "1.1.0"
[ "$status" -eq 0 ]
@ -149,7 +149,7 @@ teardown() {
}
@test "local should set a path:dir if dir exists " {
mkdir -p $PROJECT_DIR/local
mkdir -p "$PROJECT_DIR/local"
run asdf local "dummy" "path:$PROJECT_DIR/local"
[ "$status" -eq 0 ]
[ "$(cat "$PROJECT_DIR/.tool-versions")" = "dummy path:$PROJECT_DIR/local" ]
@ -174,24 +174,24 @@ teardown() {
}
@test "local -p/--parent should allow multiple versions" {
cd $CHILD_DIR
touch $PROJECT_DIR/.tool-versions
cd "$CHILD_DIR"
touch "$PROJECT_DIR/.tool-versions"
run asdf local -p "dummy" "1.1.0" "1.0.0"
[ "$status" -eq 0 ]
[ "$(cat "$PROJECT_DIR/.tool-versions")" = "dummy 1.1.0 1.0.0" ]
}
@test "local -p/--parent should overwrite the existing version if it's set" {
cd $CHILD_DIR
echo 'dummy 1.0.0' >>$PROJECT_DIR/.tool-versions
cd "$CHILD_DIR"
echo 'dummy 1.0.0' >>"$PROJECT_DIR/.tool-versions"
run asdf local -p "dummy" "1.1.0"
[ "$status" -eq 0 ]
[ "$(cat "$PROJECT_DIR/.tool-versions")" = "dummy 1.1.0" ]
}
@test "local -p/--parent should set the version if it's unset" {
cd $CHILD_DIR
touch $PROJECT_DIR/.tool-versions
cd "$CHILD_DIR"
touch "$PROJECT_DIR/.tool-versions"
run asdf local -p "dummy" "1.1.0"
[ "$status" -eq 0 ]
[ "$(cat "$PROJECT_DIR/.tool-versions")" = "dummy 1.1.0" ]
@ -246,14 +246,14 @@ teardown() {
}
@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"
[ "$status" -eq 0 ]
[ "$(cat "$HOME/.tool-versions")" = "dummy 1.1.0" ]
}
@test "global should append trailing newline before appending new version when missing" {
echo -n 'foobar 1.0.0' >>$HOME/.tool-versions
echo -n 'foobar 1.0.0' >>"$HOME/.tool-versions"
run asdf global "dummy" "1.1.0"
[ "$status" -eq 0 ]
@ -261,7 +261,7 @@ teardown() {
}
@test "global should not append trailing newline before appending new version when one present" {
echo 'foobar 1.0.0' >>$HOME/.tool-versions
echo 'foobar 1.0.0' >>"$HOME/.tool-versions"
run asdf global "dummy" "1.1.0"
[ "$status" -eq 0 ]
@ -275,7 +275,7 @@ teardown() {
}
@test "global should set a path:dir if dir exists " {
mkdir -p $PROJECT_DIR/local
mkdir -p "$PROJECT_DIR/local"
run asdf global "dummy" "path:$PROJECT_DIR/local"
[ "$status" -eq 0 ]
[ "$(cat "$HOME/.tool-versions")" = "dummy path:$PROJECT_DIR/local" ]
@ -341,9 +341,9 @@ teardown() {
}
@test "global should preserve symlinks when setting versions" {
mkdir $HOME/other-dir
touch $HOME/other-dir/.tool-versions
ln -s other-dir/.tool-versions $HOME/.tool-versions
mkdir "$HOME/other-dir"
touch "$HOME/other-dir/.tool-versions"
ln -s other-dir/.tool-versions "$HOME/.tool-versions"
run asdf global "dummy" "1.1.0"
[ "$status" -eq 0 ]
@ -352,9 +352,9 @@ teardown() {
}
@test "global should preserve symlinks when updating versions" {
mkdir $HOME/other-dir
touch $HOME/other-dir/.tool-versions
ln -s other-dir/.tool-versions $HOME/.tool-versions
mkdir "$HOME/other-dir"
touch "$HOME/other-dir/.tool-versions"
ln -s other-dir/.tool-versions "$HOME/.tool-versions"
run asdf global "dummy" "1.1.0"
run asdf global "dummy" "1.1.0"
@ -465,28 +465,28 @@ false"
}
@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"
[ "$status" -eq 0 ]
[ "$(cat "$HOME/.tool-versions")" = "dummy 1.0.0 2.0.0" ]
}
@test "[global - dummy_legacy_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"
[ "$status" -eq 0 ]
[ "$(cat "$HOME/.tool-versions")" = "legacy-dummy 1.0.0 5.1.0" ]
}
@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"
[ "$status" -eq 0 ]
[ "$(cat "$PROJECT_DIR/.tool-versions")" = "dummy 1.0.0 2.0.0" ]
}
@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"
[ "$status" -eq 0 ]
[ "$(cat "$PROJECT_DIR/.tool-versions")" = "legacy-dummy 1.0.0 5.1.0" ]

View File

@ -27,7 +27,7 @@ function teardown() {
}
@test "where shows install location of current version if no version specified" {
echo 'dummy 2.1' >>$HOME/.tool-versions
echo 'dummy 2.1' >>"$HOME/.tool-versions"
run asdf where 'dummy'
@ -36,7 +36,7 @@ function teardown() {
}
@test "where shows install location of first current version if not version specified and multiple current versions" {
echo 'dummy 2.1 1.0' >>$HOME/.tool-versions
echo 'dummy 2.1 1.0' >>"$HOME/.tool-versions"
run asdf where 'dummy'
[ "$status" -eq 0 ]
[ "$output" = "$ASDF_DIR/installs/dummy/2.1" ]

View File

@ -18,7 +18,7 @@ teardown() {
}
@test "which should show dummy 1.0 main binary" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf which "dummy"
[ "$status" -eq 0 ]
@ -26,7 +26,7 @@ teardown() {
}
@test "which should fail for unknown binary" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf which "sunny"
[ "$status" -eq 1 ]
@ -34,7 +34,7 @@ teardown() {
}
@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"
chmod +x "$ASDF_DIR/plugins/dummy/bin/list-bin-paths"
@ -46,12 +46,12 @@ teardown() {
}
@test "which should show path of system version" {
echo 'dummy system' >$PROJECT_DIR/.tool-versions
cd $PROJECT_DIR
echo 'dummy system' >"$PROJECT_DIR/.tool-versions"
cd "$PROJECT_DIR"
mkdir $PROJECT_DIR/sys
touch $PROJECT_DIR/sys/dummy
chmod +x $PROJECT_DIR/sys/dummy
mkdir "$PROJECT_DIR/sys"
touch "$PROJECT_DIR/sys/dummy"
chmod +x "$PROJECT_DIR/sys/dummy"
run env "PATH=$PATH:$PROJECT_DIR/sys" asdf which "dummy"
[ "$status" -eq 0 ]
@ -59,8 +59,8 @@ teardown() {
}
@test "which report when missing executable on system version" {
echo 'dummy system' >$PROJECT_DIR/.tool-versions
cd $PROJECT_DIR
echo 'dummy system' >"$PROJECT_DIR/.tool-versions"
cd "$PROJECT_DIR"
run asdf which "dummy"
[ "$status" -eq 1 ]
@ -68,7 +68,7 @@ teardown() {
}
@test "which should inform when no binary is found" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
run asdf which "bazbat"
[ "$status" -eq 1 ]
@ -76,7 +76,7 @@ teardown() {
}
@test "which should use path returned by exec-path when present" {
cd $PROJECT_DIR
cd "$PROJECT_DIR"
install_dummy_exec_path_script "dummy"
run asdf which "dummy"
@ -85,7 +85,7 @@ teardown() {
}
@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 '1.1' >>"$PROJECT_DIR/.dummy-version"
@ -98,8 +98,8 @@ teardown() {
}
@test "which should not return shim path" {
cd $PROJECT_DIR
echo 'dummy 1.0' >$PROJECT_DIR/.tool-versions
cd "$PROJECT_DIR"
echo 'dummy 1.0' >"$PROJECT_DIR/.tool-versions"
rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
run env PATH="$PATH:$ASDF_DIR/shims" asdf which dummy