From 491ef2a9f21eca25e2f2b85f0a625e4938f42e8f Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Mon, 10 Apr 2023 20:58:58 -0700 Subject: [PATCH] test: rm useless `echo` usage in tests (#1535) --- test/latest_command.bats | 17 ++--------------- test/list_command.bats | 24 ++++++++++++------------ test/plugin_test_command.bats | 4 ---- test/shim_exec.bats | 1 - test/uninstall_command.bats | 2 +- test/update_command.bats | 4 ++-- test/utils.bats | 1 - 7 files changed, 17 insertions(+), 36 deletions(-) diff --git a/test/latest_command.bats b/test/latest_command.bats index 795327df..9c0bd5af 100644 --- a/test/latest_command.bats +++ b/test/latest_command.bats @@ -38,48 +38,36 @@ teardown() { #################################################### @test "[latest_command - dummy_legacy_plugin] shows latest stable version" { run asdf latest legacy-dummy - echo "status: $status" - echo "output: $output" [ "5.1.0" = "$output" ] [ "$status" -eq 0 ] } @test "[latest_command - dummy_legacy_plugin] shows latest stable version that matches the given string" { run asdf latest legacy-dummy 1 - echo "status: $status" - echo "output: $output" [ "1.1.0" = "$output" ] [ "$status" -eq 0 ] } @test "[latest_command - dummy_legacy_plugin] No stable version should return an error" { run asdf latest legacy-dummy 3 - echo "status: $status" - echo "output: $output" [ -z "$output" ] [ "$status" -eq 1 ] } @test "[latest_command - dummy_legacy_plugin] do not show latest unstable version that matches the given string" { run asdf latest legacy-dummy 4 - echo "status: $status" - echo "output: $output" [ "4.0.0" = "$output" ] [ "$status" -eq 0 ] } @test "[latest_command - dummy_legacy_plugin] do not show latest unstable version with capital characters that matches the given string" { run asdf latest legacy-dummy 5 - echo "status: $status" - echo "output: $output" [ "5.1.0" = "$output" ] [ "$status" -eq 0 ] } @test "[latest_command - dummy_legacy_plugin] an invalid version should return an error" { run asdf latest legacy-dummy 6 - echo "status: $status" - echo "output: $output" [ "No compatible versions available (legacy-dummy 6)" = "$output" ] [ "$status" -eq 1 ] } @@ -91,13 +79,12 @@ teardown() { run asdf install dummy 2.0.0 run asdf install legacy-dummy 4.0.0 run asdf latest --all - echo "output $output" - [ "$(echo -e "dummy\t2.0.0\tinstalled\nlegacy-dummy\t5.1.0\tmissing\n")" = "$output" ] + [ $'dummy\t2.0.0\tinstalled\nlegacy-dummy\t5.1.0\tmissing' = "$output" ] [ "$status" -eq 0 ] } @test "[latest_command - all plugins] not installed plugin should return missing" { run asdf latest --all - [ "$(echo -e "dummy\t2.0.0\tmissing\nlegacy-dummy\t5.1.0\tmissing\n")" = "$output" ] + [ $'dummy\t2.0.0\tmissing\nlegacy-dummy\t5.1.0\tmissing' = "$output" ] [ "$status" -eq 0 ] } diff --git a/test/list_command.bats b/test/list_command.bats index 10230465..f21f2cd1 100644 --- a/test/list_command.bats +++ b/test/list_command.bats @@ -19,8 +19,8 @@ teardown() { run asdf install dummy 1.0.0 run asdf install dummy 1.1.0 run asdf list - [[ "$output" == *"$(echo -e "dummy\n 1.0.0\n 1.1.0")"* ]] - [[ "$output" == *"$(echo -e "dummy-broken\n No versions installed")"* ]] + [[ "$output" == *$'dummy\n 1.0.0\n 1.1.0'* ]] + [[ "$output" == *$'dummy-broken\n No versions installed'* ]] [ "$status" -eq 0 ] } @@ -31,8 +31,8 @@ teardown() { run asdf install dummy 1.1.0 run asdf list - [[ "$output" == *"$(echo -e "dummy\n 1.0.0\n *1.1.0")"* ]] - [[ "$output" == *"$(echo -e "dummy-broken\n No versions installed")"* ]] + [[ "$output" == *$'dummy\n 1.0.0\n *1.1.0'* ]] + [[ "$output" == *$'dummy-broken\n No versions installed'* ]] [ "$status" -eq 0 ] } @@ -43,10 +43,10 @@ teardown() { run asdf install dummy 1.0.0 run asdf install tummy 2.0.0 run asdf list - [[ "$output" == *"$(echo -e "dummy\n 1.0.0")"* ]] - [[ "$output" == *"$(echo -e "dummy-broken\n No versions installed")"* ]] - [[ "$output" == *"$(echo -e "mummy\n No versions installed")"* ]] - [[ "$output" == *"$(echo -e "tummy\n 2.0.0")"* ]] + [[ "$output" == *$'dummy\n 1.0.0'* ]] + [[ "$output" == *$'dummy-broken\n No versions installed'* ]] + [[ "$output" == *$'mummy\n No versions installed'* ]] + [[ "$output" == *$'tummy\n 2.0.0'* ]] [ "$status" -eq 0 ] } @@ -54,7 +54,7 @@ teardown() { run asdf install dummy 1.0.0 run asdf install dummy 1.1.0 run asdf list dummy - [ "$(echo -e " 1.0.0\n 1.1.0")" = "$output" ] + [ $' 1.0.0\n 1.1.0' = "$output" ] [ "$status" -eq 0 ] } @@ -63,7 +63,7 @@ teardown() { run asdf install dummy 1.1 run asdf install dummy 2.0 run asdf list dummy 1 - [ "$(echo -e " 1.0\n 1.1")" = "$output" ] + [ $' 1.0\n 1.1' = "$output" ] [ "$status" -eq 0 ] } @@ -77,13 +77,13 @@ teardown() { @test "list_all_command lists available versions" { run asdf list-all dummy - [ "$(echo -e "1.0.0\n1.1.0\n2.0.0")" = "$output" ] + [ $'1.0.0\n1.1.0\n2.0.0' = "$output" ] [ "$status" -eq 0 ] } @test "list_all_command with version filters available versions" { run asdf list-all dummy 1 - [ "$(echo -e "1.0.0\n1.1.0")" = "$output" ] + [ $'1.0.0\n1.1.0' = "$output" ] [ "$status" -eq 0 ] } diff --git a/test/plugin_test_command.bats b/test/plugin_test_command.bats index 1b486649..c725450c 100644 --- a/test/plugin_test_command.bats +++ b/test/plugin_test_command.bats @@ -25,14 +25,10 @@ teardown() { @test "plugin_test_command works with no options provided" { run asdf plugin-test dummy "${BASE_DIR}/repo-dummy" - echo "status = ${status}" - echo "output = ${output}" [ "$status" -eq 0 ] } @test "plugin_test_command works with all options provided" { run asdf plugin-test dummy "${BASE_DIR}/repo-dummy" --asdf-tool-version 1.0.0 --asdf-plugin-gitref master - echo "status = ${status}" - echo "output = ${output}" [ "$status" -eq 0 ] } diff --git a/test/shim_exec.bats b/test/shim_exec.bats index 838b1a9e..5c6d0673 100644 --- a/test/shim_exec.bats +++ b/test/shim_exec.bats @@ -333,7 +333,6 @@ teardown() { chmod +x "$PROJECT_DIR/sys/dummy" run env "PATH=$PATH:$PROJECT_DIR/sys" "$ASDF_DIR/shims/dummy" - echo "$status $output" [ "$output" = "$ASDF_DIR/shims/dummy" ] } diff --git a/test/uninstall_command.bats b/test/uninstall_command.bats index a5513468..c5bef1b4 100644 --- a/test/uninstall_command.bats +++ b/test/uninstall_command.bats @@ -32,7 +32,7 @@ teardown() { run asdf install dummy 1.1.0 [ "$status" -eq 0 ] mkdir -p "$ASDF_DIR/plugins/dummy/bin" - echo "echo custom uninstall" >"$ASDF_DIR/plugins/dummy/bin/uninstall" + printf '%s\n' "echo custom uninstall" >"$ASDF_DIR/plugins/dummy/bin/uninstall" chmod 755 "$ASDF_DIR/plugins/dummy/bin/uninstall" run asdf uninstall dummy 1.1.0 [ "$output" = "custom uninstall" ] diff --git a/test/update_command.bats b/test/update_command.bats index c8333673..9e377f16 100644 --- a/test/update_command.bats +++ b/test/update_command.bats @@ -61,14 +61,14 @@ teardown() { touch "$ASDF_DIR/asdf_updates_disabled" run asdf update [ "$status" -eq 42 ] - [ "$(echo -e "Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.")" = "$output" ] + [ $'Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.' = "$output" ] } @test "asdf update is a noop for non-git repos" { rm -rf "$ASDF_DIR/.git/" run asdf update [ "$status" -eq 42 ] - [ "$(echo -e "Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.")" = "$output" ] + [ $'Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.' = "$output" ] } @test "asdf update fails with exit code 1" { diff --git a/test/utils.bats b/test/utils.bats index 288a2e22..5e5c94f7 100644 --- a/test/utils.bats +++ b/test/utils.bats @@ -43,7 +43,6 @@ teardown() { run get_download_path foo version "1.0.0" [ "$status" -eq 0 ] download_path=${output#"$HOME/"} - echo "$download_path" [ "$download_path" = ".asdf/downloads/foo/1.0.0" ] }