2017-07-26 13:00:55 -07:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helpers
|
|
|
|
|
|
|
|
setup() {
|
2021-07-19 21:21:39 -07:00
|
|
|
ASDF_BATS_SPACE_IN_PATH=true setup_asdf_dir
|
2017-07-26 13:00:55 -07:00
|
|
|
install_dummy_plugin
|
|
|
|
|
2021-07-19 21:21:39 -07:00
|
|
|
PROJECT_DIR="$HOME/project"
|
|
|
|
mkdir "$PROJECT_DIR"
|
2017-07-26 13:00:55 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
teardown() {
|
|
|
|
clean_asdf_dir
|
|
|
|
}
|
|
|
|
|
2019-05-17 09:33:16 -07:00
|
|
|
@test "reshim should allow prefixes of other versions" {
|
|
|
|
run asdf install dummy 1.0.1
|
|
|
|
run asdf install dummy 1.0
|
|
|
|
|
|
|
|
run asdf reshim
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
run grep "asdf-plugin: dummy 1.0.1" "$ASDF_DIR/shims/dummy"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run grep "asdf-plugin: dummy 1.0\$" "$ASDF_DIR/shims/dummy"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
2017-07-26 13:00:55 -07:00
|
|
|
@test "reshim command should remove shims of removed binaries" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
2017-07-26 13:00:55 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim dummy
|
2017-07-26 13:00:55 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
|
|
|
|
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim dummy
|
2017-07-26 13:00:55 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ ! -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "reshim should remove metadata of removed binaries" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
|
|
|
run asdf install dummy 1.1
|
2017-07-26 13:00:55 -07:00
|
|
|
|
|
|
|
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim dummy
|
2017-07-26 13:00:55 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
2019-01-19 03:12:52 -07:00
|
|
|
run grep "asdf-plugin: dummy 1.0" "$ASDF_DIR/shims/dummy"
|
2017-07-26 13:00:55 -07:00
|
|
|
[ "$status" -eq 1 ]
|
2019-01-19 03:12:52 -07:00
|
|
|
run grep "asdf-plugin: dummy 1.1" "$ASDF_DIR/shims/dummy"
|
2017-07-26 13:00:55 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
2017-10-25 12:05:59 -07:00
|
|
|
|
2019-05-17 11:21:52 -07:00
|
|
|
@test "reshim should not remove metadata of removed prefix versions" {
|
|
|
|
run asdf install dummy 1.0
|
|
|
|
run asdf install dummy 1.0.1
|
|
|
|
run rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
|
|
|
|
run asdf reshim dummy
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
run grep "asdf-plugin: dummy 1.0.1" "$ASDF_DIR/shims/dummy"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
2017-10-25 12:05:59 -07:00
|
|
|
@test "reshim should not duplicate shims" {
|
2021-07-19 21:21:39 -07:00
|
|
|
cd "$PROJECT_DIR"
|
2017-10-25 12:19:03 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
|
|
|
run asdf install dummy 1.1
|
2017-10-25 12:05:59 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
|
2021-07-19 21:21:39 -07:00
|
|
|
run rm "$ASDF_DIR/shims/"*
|
2017-10-25 12:05:59 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2021-07-19 21:21:39 -07:00
|
|
|
[ "0" -eq "$(ls "$ASDF_DIR/shims/"dummy* | wc -l)" ]
|
2017-10-25 12:05:59 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim dummy
|
2017-10-25 12:05:59 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2021-07-19 21:21:39 -07:00
|
|
|
[ "1" -eq "$(ls "$ASDF_DIR/shims/"dummy* | wc -l)" ]
|
2017-10-25 12:14:19 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim dummy
|
2017-10-25 12:14:19 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2021-07-19 21:21:39 -07:00
|
|
|
[ "1" -eq "$(ls "$ASDF_DIR/shims/"dummy* | wc -l)" ]
|
2017-10-26 12:58:45 -07:00
|
|
|
}
|
2018-09-19 05:00:11 -07:00
|
|
|
|
|
|
|
@test "reshim should create shims only for files and not folders" {
|
2021-07-19 21:21:39 -07:00
|
|
|
cd "$PROJECT_DIR"
|
2018-09-19 05:00:11 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
|
|
|
run asdf install dummy 1.1
|
2018-09-19 05:00:11 -07:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ -f "$ASDF_DIR/shims/dummy" ]
|
|
|
|
[ ! -f "$ASDF_DIR/shims/subdir" ]
|
|
|
|
|
2021-07-19 21:21:39 -07:00
|
|
|
run rm "$ASDF_DIR/shims/"*
|
2018-09-19 05:00:11 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2021-07-19 21:21:39 -07:00
|
|
|
[ "0" -eq "$(ls "$ASDF_DIR/shims/"dummy* | wc -l)" ]
|
|
|
|
[ "0" -eq "$(ls "$ASDF_DIR/shims/"subdir* | wc -l)" ]
|
2018-09-19 05:00:11 -07:00
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim dummy
|
2018-09-19 05:00:11 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2021-07-19 21:21:39 -07:00
|
|
|
[ "1" -eq "$(ls "$ASDF_DIR/shims/"dummy* | wc -l)" ]
|
|
|
|
[ "0" -eq "$(ls "$ASDF_DIR/shims/"subdir* | wc -l)" ]
|
2018-09-19 05:00:11 -07:00
|
|
|
|
|
|
|
}
|
2019-01-19 03:12:52 -07:00
|
|
|
|
|
|
|
@test "reshim without arguments reshims all installed plugins" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
2021-07-19 21:21:39 -07:00
|
|
|
run rm "$ASDF_DIR/shims/"*
|
2019-01-19 03:12:52 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2021-07-19 21:21:39 -07:00
|
|
|
[ "0" -eq "$(ls "$ASDF_DIR/shims/"dummy* | wc -l)" ]
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim
|
2019-01-19 03:12:52 -07:00
|
|
|
[ "$status" -eq 0 ]
|
2021-07-19 21:21:39 -07:00
|
|
|
[ "1" -eq "$(ls "$ASDF_DIR/shims/"dummy* | wc -l)" ]
|
2019-01-19 03:12:52 -07:00
|
|
|
}
|
2019-01-19 12:00:33 -07:00
|
|
|
|
2019-01-19 12:16:13 -07:00
|
|
|
@test "reshim command executes configured pre hook" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
2019-01-19 12:16:13 -07:00
|
|
|
|
2022-06-24 02:20:27 -07:00
|
|
|
cat >"$HOME/.asdfrc" <<-'EOM'
|
2019-01-19 12:16:13 -07:00
|
|
|
pre_asdf_reshim_dummy = echo RESHIM
|
|
|
|
EOM
|
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim dummy 1.0
|
2019-01-19 12:16:13 -07:00
|
|
|
[ "$output" == "RESHIM" ]
|
|
|
|
}
|
|
|
|
|
2019-01-19 12:00:33 -07:00
|
|
|
@test "reshim command executes configured post hook" {
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf install dummy 1.0
|
2019-01-19 12:00:33 -07:00
|
|
|
|
2022-06-24 02:20:27 -07:00
|
|
|
cat >"$HOME/.asdfrc" <<-'EOM'
|
2019-01-19 12:00:33 -07:00
|
|
|
post_asdf_reshim_dummy = echo RESHIM
|
|
|
|
EOM
|
|
|
|
|
2019-01-20 01:13:20 -07:00
|
|
|
run asdf reshim dummy 1.0
|
2019-01-19 12:00:33 -07:00
|
|
|
[ "$output" == "RESHIM" ]
|
|
|
|
}
|