Skip to content

Commit

Permalink
chore: Fix ShellCheck errors in tests (#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperupcall authored Jan 22, 2023
1 parent 998180e commit 6f64aa8
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 58 deletions.
34 changes: 17 additions & 17 deletions test/install_command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ teardown() {
@test "install_command set ASDF_CONCURRENCY" {
run asdf install dummy 1.0.0
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.0.0/env ]
run grep ASDF_CONCURRENCY $ASDF_DIR/installs/dummy/1.0.0/env
[ -f "$ASDF_DIR/installs/dummy/1.0.0/env" ]
run grep ASDF_CONCURRENCY "$ASDF_DIR/installs/dummy/1.0.0/env"
[ "$status" -eq 0 ]
}

Expand All @@ -67,16 +67,16 @@ teardown() {
@test "install_command should create a shim with asdf-plugin metadata" {
run asdf install dummy 1.0.0
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.0.0/env ]
run grep "asdf-plugin: dummy 1.0.0" $ASDF_DIR/shims/dummy
[ -f "$ASDF_DIR/installs/dummy/1.0.0/env" ]
run grep "asdf-plugin: dummy 1.0.0" "$ASDF_DIR/shims/dummy"
[ "$status" -eq 0 ]
}

@test "install_command should create a shim with asdf-plugin metadata for plugins without download script" {
run asdf install legacy-dummy 1.0.0
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/legacy-dummy/1.0.0/env ]
run grep "asdf-plugin: legacy-dummy 1.0.0" $ASDF_DIR/shims/dummy
[ -f "$ASDF_DIR/installs/legacy-dummy/1.0.0/env" ]
run grep "asdf-plugin: legacy-dummy 1.0.0" "$ASDF_DIR/shims/dummy"
[ "$status" -eq 0 ]
}

Expand Down Expand Up @@ -130,7 +130,7 @@ teardown() {
run asdf install dummy
[ "$status" -eq 1 ]
[ "$output" = "No versions specified for dummy in config files or environment" ]
[ ! -f $ASDF_DIR/installs/dummy/1.1.0/version ]
[ ! -f "$ASDF_DIR/installs/dummy/1.1.0/version" ]
}

@test "install_command fails if the plugin is not installed" {
Expand All @@ -156,16 +156,16 @@ teardown() {
run asdf install other-dummy
[ "$status" -eq 1 ]
[ "$output" = "No versions specified for other-dummy in config files or environment" ]
[ ! -f $ASDF_DIR/installs/dummy/1.0.0/version ]
[ ! -f "$ASDF_DIR/installs/dummy/1.0.0/version" ]
}

@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
run asdf install dummy other-dummy
[ "$status" -eq 1 ]
[ "$output" = "Dummy couldn't install version: other-dummy (on purpose)" ]
[ ! -f $ASDF_DIR/installs/dummy/1.0.0/version ]
[ ! -f $ASDF_DIR/installs/other-dummy/2.0.0/version ]
[ ! -f "$ASDF_DIR/installs/dummy/1.0.0/version" ]
[ ! -f "$ASDF_DIR/installs/other-dummy/2.0.0/version" ]
}

@test "install_command without arguments uses a parent directory .tool-versions file if present" {
Expand Down Expand Up @@ -199,7 +199,7 @@ teardown() {
@test "install_command doesn't install system version" {
run asdf install dummy system
[ "$status" -eq 0 ]
[ ! -f $ASDF_DIR/installs/dummy/system/version ]
[ ! -f "$ASDF_DIR/installs/dummy/system/version" ]
}

@test "install command executes configured pre plugin install hook" {
Expand All @@ -226,8 +226,8 @@ EOM
cd $PROJECT_DIR
run asdf install
[ "$status" -eq 0 ]
[ "$output" = "" ]
[ -f $ASDF_DIR/installs/dummy/1.2.0/version ]
[ -z "$output" ]
[ -f "$ASDF_DIR/installs/dummy/1.2.0/version" ]
}

@test "install command without arguments installs versions from legacy files in parent directories" {
Expand All @@ -239,8 +239,8 @@ EOM

run asdf install
[ "$status" -eq 0 ]
[ "$output" = "" ]
[ -f $ASDF_DIR/installs/dummy/1.2.0/version ]
[ -z "$output" ]
[ -f "$ASDF_DIR/installs/dummy/1.2.0/version" ]
}

@test "install_command latest installs latest stable version" {
Expand Down Expand Up @@ -282,7 +282,7 @@ EOM
run asdf install dummy-broken 1.0.0
echo $output
[ "$status" -eq 1 ]
[ ! -d $ASDF_DIR/downloads/dummy-broken/1.1.0 ]
[ ! -d $ASDF_DIR/installs/dummy-broken/1.1.0 ]
[ ! -d "$ASDF_DIR/downloads/dummy-broken/1.1.0" ]
[ ! -d "$ASDF_DIR/installs/dummy-broken/1.1.0" ]
[ "$output" = "Download failed!" ]
}
14 changes: 7 additions & 7 deletions test/plugin_update_command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,31 @@ teardown() {
[ "$(cat "$ASDF_DIR/installs/dummy/1.1/version")" = "1.1" ]
run asdf plugin-update dummy
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.1/version ]
[ -f "$ASDF_DIR/installs/dummy/1.1/version" ]
run asdf plugin-update --all
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.1/version ]
[ -f "$ASDF_DIR/installs/dummy/1.1/version" ]
}

@test "asdf plugin-update should not remove plugins" {
# dummy plugin is already installed
run asdf plugin-update dummy
[ "$status" -eq 0 ]
[ -d $ASDF_DIR/plugins/dummy ]
[ -d "$ASDF_DIR/plugins/dummy" ]
run asdf plugin-update --all
[ "$status" -eq 0 ]
[ -d $ASDF_DIR/plugins/dummy ]
[ -d "$ASDF_DIR/plugins/dummy" ]
}

@test "asdf plugin-update should not remove shims" {
run asdf install dummy 1.1
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
run asdf plugin-update dummy
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
run asdf plugin-update --all
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
}

@test "asdf plugin-update done for all plugins" {
Expand Down
10 changes: 5 additions & 5 deletions test/remove_command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@ teardown() {
install_dummy_plugin
run asdf install dummy 1.0
[ "$status" -eq 0 ]
[ -d $ASDF_DIR/installs/dummy ]
[ -d "$ASDF_DIR/installs/dummy" ]

run asdf plugin-remove dummy
[ "$status" -eq 0 ]
[ ! -d $ASDF_DIR/installs/dummy ]
[ ! -d "$ASDF_DIR/installs/dummy" ]
}

@test "plugin_remove_command should also remove shims for that plugin" {
install_dummy_plugin
run asdf install dummy 1.0
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]

run asdf plugin-remove dummy
[ "$status" -eq 0 ]
[ ! -f $ASDF_DIR/shims/dummy ]
[ ! -f "$ASDF_DIR/shims/dummy" ]
}

@test "plugin_remove_command should not remove unrelated shims" {
Expand All @@ -63,7 +63,7 @@ teardown() {
[ "$status" -eq 0 ]

# unrelated shim should exist
[ -f $ASDF_DIR/shims/gummy ]
[ -f "$ASDF_DIR/shims/gummy" ]
}

@test "plugin_remove_command executes pre-plugin-remove script" {
Expand Down
4 changes: 2 additions & 2 deletions test/shim_exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ teardown() {
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
run asdf install

echo "tr [:lower:] [:upper:]" >$ASDF_DIR/installs/dummy/1.0/bin/upper
chmod +x $ASDF_DIR/installs/dummy/1.0/bin/upper
echo "tr [:lower:] [:upper:]" >"$ASDF_DIR/installs/dummy/1.0/bin/upper"
chmod +x "$ASDF_DIR/installs/dummy/1.0/bin/upper"

run asdf reshim dummy 1.0

Expand Down
26 changes: 13 additions & 13 deletions test/uninstall_command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ teardown() {
[ "$status" -eq 0 ]
[ "$(cat "$ASDF_DIR/installs/dummy/1.1.0/version")" = "1.1.0" ]
run asdf uninstall dummy 1.1.0
[ ! -f $ASDF_DIR/installs/dummy/1.1.0/version ]
[ ! -f "$ASDF_DIR/installs/dummy/1.1.0/version" ]
}

@test "uninstall_command should invoke the plugin bin/uninstall if available" {
Expand All @@ -41,29 +41,29 @@ teardown() {

@test "uninstall_command should remove the plugin shims if no other version is installed" {
run asdf install dummy 1.1.0
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
run asdf uninstall dummy 1.1.0
[ ! -f $ASDF_DIR/shims/dummy ]
[ ! -f "$ASDF_DIR/shims/dummy" ]
}

@test "uninstall_command should leave the plugin shims if other version is installed" {
run asdf install dummy 1.0.0
[ -f $ASDF_DIR/installs/dummy/1.0.0/bin/dummy ]
[ -f "$ASDF_DIR/installs/dummy/1.0.0/bin/dummy" ]

run asdf install dummy 1.1.0
[ -f $ASDF_DIR/installs/dummy/1.1.0/bin/dummy ]
[ -f "$ASDF_DIR/installs/dummy/1.1.0/bin/dummy" ]

[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
run asdf uninstall dummy 1.0.0
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
}

@test "uninstall_command should remove relevant asdf-plugin metadata" {
run asdf install dummy 1.0.0
[ -f $ASDF_DIR/installs/dummy/1.0.0/bin/dummy ]
[ -f "$ASDF_DIR/installs/dummy/1.0.0/bin/dummy" ]

run asdf install dummy 1.1.0
[ -f $ASDF_DIR/installs/dummy/1.1.0/bin/dummy ]
[ -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
Expand All @@ -74,13 +74,13 @@ teardown() {

@test "uninstall_command should not remove other unrelated shims" {
run asdf install dummy 1.0.0
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]

touch $ASDF_DIR/shims/gummy
[ -f $ASDF_DIR/shims/gummy ]
touch "$ASDF_DIR/shims/gummy"
[ -f "$ASDF_DIR/shims/gummy" ]

run asdf uninstall dummy 1.0.0
[ -f $ASDF_DIR/shims/gummy ]
[ -f "$ASDF_DIR/shims/gummy" ]
}

@test "uninstall command executes configured pre hook" {
Expand Down
22 changes: 11 additions & 11 deletions test/update_command.bats
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ teardown() {
if [ -n "$tag" ]; then
run asdf update
[ "$status" -eq 0 ]
cd $ASDF_DIR
git tag | grep $tag
cd "$ASDF_DIR"
git tag | grep "$tag"
[ "$?" -eq 0 ]
fi
}
Expand All @@ -53,8 +53,8 @@ teardown() {
echo "use_release_candidates = yes" >$ASDF_CONFIG_DEFAULT_FILE
run asdf update
[ "$status" -eq 0 ]
cd $ASDF_DIR
git tag | grep $tag
cd "$ASDF_DIR"
git tag | grep "$tag"
[ "$?" -eq 0 ]
fi
}
Expand Down Expand Up @@ -85,29 +85,29 @@ teardown() {
[ "$(cat "$ASDF_DIR/installs/dummy/1.1.0/version")" = "1.1.0" ]
run asdf update
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.1.0/version ]
[ -f "$ASDF_DIR/installs/dummy/1.1.0/version" ]
run asdf update --head
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/installs/dummy/1.1.0/version ]
[ -f "$ASDF_DIR/installs/dummy/1.1.0/version" ]
}

@test "asdf update should not remove plugins" {
# dummy plugin is already installed
run asdf update
[ "$status" -eq 0 ]
[ -d $ASDF_DIR/plugins/dummy ]
[ -d "$ASDF_DIR/plugins/dummy" ]
run asdf update --head
[ "$status" -eq 0 ]
[ -d $ASDF_DIR/plugins/dummy ]
[ -d "$ASDF_DIR/plugins/dummy" ]
}

@test "asdf update should not remove shims" {
run asdf install dummy 1.1.0
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
run asdf update
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
run asdf update --head
[ "$status" -eq 0 ]
[ -f $ASDF_DIR/shims/dummy ]
[ -f "$ASDF_DIR/shims/dummy" ]
}
6 changes: 3 additions & 3 deletions test/utils.bats
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ teardown() {

run resolve_symlink bar
[ "$status" -eq 0 ]
[ "$output" = $PWD/foo ]
[ "$output" = "$PWD/foo" ]
rm -f foo bar
}

Expand All @@ -380,7 +380,7 @@ teardown() {

run resolve_symlink baz/bar
[ "$status" -eq 0 ]
[ "$output" = $PWD/baz/../foo ]
[ "$output" = "$PWD/baz/../foo" ]
rm -f foo bar
}

Expand All @@ -390,7 +390,7 @@ teardown() {

run resolve_symlink bar
[ "$status" -eq 0 ]
[ "$output" = $PWD/foo ]
[ "$output" = "$PWD/foo" ]
rm -f foo bar
}

Expand Down

0 comments on commit 6f64aa8

Please sign in to comment.