Test that command being executed can see other tools shims on path

This commit is contained in:
Victor Hugo Borja 2019-01-23 22:18:18 -06:00
parent 3f3e0f52c5
commit 4b40e80776
3 changed files with 38 additions and 8 deletions

View File

@ -492,10 +492,6 @@ with_plugin_env() {
# create a new subshell to keep env
(
# first remove asdf shims from the path
PATH=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g")
export PATH
if [ "$version" = "system" ]; then
# execute as is for system
"$callback"
@ -638,7 +634,12 @@ with_shim_executable() {
plugin_path=$(get_plugin_path "$plugin_name")
run_within_env() {
executable_path=$(command -v "$shim_name")
local path=$PATH
if [ "system" == "$full_version" ]; then
path=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g")
fi
executable_path=$(PATH=$path command -v "$shim_name")
if [ -x "${plugin_path}/bin/exec-path" ]; then
install_path=$(find_install_path "$plugin_name" "$full_version")

View File

@ -63,6 +63,6 @@ teardown() {
[ "$status" -eq 1 ]
run asdf env dummy which dummy
[ "$output" == "" ]
[ "$status" -eq 1 ]
[ "$output" == "$ASDF_DIR/shims/dummy" ]
[ "$status" -eq 0 ]
}

View File

@ -251,6 +251,34 @@ teardown() {
[ "$output" == "$ASDF_DIR/installs/dummy/2.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
echo "dummy 2.0" > $PROJECT_DIR/.tool-versions
echo "gummy 2.0" >> $PROJECT_DIR/.tool-versions
run asdf install
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 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
run asdf reshim
run $ASDF_DIR/shims/foo
[ "$output" == "$ASDF_DIR/installs/dummy/2.0/bin/dummy" ]
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
@ -261,7 +289,8 @@ teardown() {
chmod +x $PROJECT_DIR/sys/dummy
run env PATH=$PATH:$PROJECT_DIR/sys $ASDF_DIR/shims/dummy
[ "$output" == "$PROJECT_DIR/sys/dummy" ]
echo $status $output
[ "$output" == "$ASDF_DIR/shims/dummy" ]
}