mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
9b27848d07
Features * New shim version meta-data allows shims to not depend on a particular plugin nor on its relative executable path (#431) Upgrading requires shim re-generation and should happen automatically by `asdf-exec`: `rm -rf ~/.asdf/shims/` followed by `asdf reshim` * Added lots of tests for shim execution. We now make sure that shim execution obeys plugins hooks like `list-bin-paths` and `exec-path`. * Shim exec is now performed by a new `bin/private/asdf-tool-exec` that might be faster for most common use case: (versions on local .tool-versions file) but fallbacks to slower `get_preset_version_for` which takes legacy formats into account. * Shim exec recommends which plugins or versions to set when command is not found. Fixed Bugs * Allow many plugins to provide shims with same executable name (#431)
101 lines
2.4 KiB
Bash
101 lines
2.4 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helpers
|
|
|
|
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/reshim.sh
|
|
. $(dirname $BATS_TEST_DIRNAME)/lib/commands/install.sh
|
|
|
|
setup() {
|
|
setup_asdf_dir
|
|
install_dummy_plugin
|
|
|
|
PROJECT_DIR=$HOME/project
|
|
mkdir $PROJECT_DIR
|
|
}
|
|
|
|
teardown() {
|
|
clean_asdf_dir
|
|
}
|
|
|
|
|
|
@test "reshim command should remove shims of removed binaries" {
|
|
run install_command dummy 1.0
|
|
[ "$status" -eq 0 ]
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
run reshim_command dummy
|
|
[ "$status" -eq 0 ]
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
|
|
run reshim_command dummy
|
|
[ "$status" -eq 0 ]
|
|
[ ! -f "$ASDF_DIR/shims/dummy" ]
|
|
}
|
|
|
|
@test "reshim should remove metadata of removed binaries" {
|
|
run install_command dummy 1.0
|
|
run install_command dummy 1.1
|
|
|
|
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
|
|
run reshim_command dummy
|
|
[ "$status" -eq 0 ]
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
run grep "asdf-plugin: dummy 1.0" "$ASDF_DIR/shims/dummy"
|
|
[ "$status" -eq 1 ]
|
|
run grep "asdf-plugin: dummy 1.1" "$ASDF_DIR/shims/dummy"
|
|
[ "$status" -eq 0 ]
|
|
}
|
|
|
|
@test "reshim should not duplicate shims" {
|
|
cd $PROJECT_DIR
|
|
|
|
run install_command dummy 1.0
|
|
run install_command dummy 1.1
|
|
[ "$status" -eq 0 ]
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
run rm $ASDF_DIR/shims/*
|
|
[ "$status" -eq 0 ]
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
|
|
run reshim_command dummy
|
|
[ "$status" -eq 0 ]
|
|
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
|
|
run reshim_command dummy
|
|
[ "$status" -eq 0 ]
|
|
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
}
|
|
|
|
@test "reshim should create shims only for files and not folders" {
|
|
cd $PROJECT_DIR
|
|
|
|
run install_command dummy 1.0
|
|
run install_command dummy 1.1
|
|
[ "$status" -eq 0 ]
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
[ ! -f "$ASDF_DIR/shims/subdir" ]
|
|
|
|
run rm $ASDF_DIR/shims/*
|
|
[ "$status" -eq 0 ]
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/subdir* | wc -l)" ]
|
|
|
|
run reshim_command dummy
|
|
[ "$status" -eq 0 ]
|
|
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/subdir* | wc -l)" ]
|
|
|
|
}
|
|
|
|
@test "reshim without arguments reshims all installed plugins" {
|
|
run install_command dummy 1.0
|
|
run rm $ASDF_DIR/shims/*
|
|
[ "$status" -eq 0 ]
|
|
[ "0" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
run reshim_command
|
|
[ "$status" -eq 0 ]
|
|
[ "1" -eq "$(ls $ASDF_DIR/shims/dummy* | wc -l)" ]
|
|
}
|