mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Test that command being executed can see other tools shims on path
This commit is contained in:
parent
3f3e0f52c5
commit
4b40e80776
11
lib/utils.sh
11
lib/utils.sh
@ -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")
|
||||
|
@ -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 ]
|
||||
}
|
||||
|
@ -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" ]
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user