From d81b81f9de2dc5961624464df04cef7cafae588c Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Sat, 14 Jan 2023 05:18:44 -0800 Subject: [PATCH] fix: Remove `==` inside `[` (#1421) * lint(checkstyle): Miscellaneous tweaks * lint(checkstyle): Add 'no-double-equals' rule * lint: Remove double equals from `[` * chore: Remove final double equals Co-authored-by: Trevor Brown --- lib/functions/versions.bash | 2 +- lib/utils.bash | 2 +- scripts/checkstyle.py | 32 ++++++++++++++++++++---- test/asdf_nu.bats | 6 ++--- test/banned_commands.bats | 4 +-- test/help_command.bats | 4 +-- test/install_command.bats | 14 +++++------ test/latest_command.bats | 20 +++++++-------- test/list_command.bats | 12 ++++----- test/reshim_command.bats | 4 +-- test/shim_env_command.bats | 8 +++--- test/shim_exec.bats | 50 ++++++++++++++++++------------------- test/uninstall_command.bats | 8 +++--- test/update_command.bats | 4 +-- test/utils.bats | 8 +++--- test/which_command.bats | 10 ++++---- 16 files changed, 105 insertions(+), 83 deletions(-) diff --git a/lib/functions/versions.bash b/lib/functions/versions.bash index 1a748c07..28262f78 100644 --- a/lib/functions/versions.bash +++ b/lib/functions/versions.bash @@ -129,7 +129,7 @@ latest_command() { local query=$2 local plugin_path - if [ "$plugin_name" == "--all" ]; then + if [ "$plugin_name" = "--all" ]; then latest_all fi diff --git a/lib/utils.bash b/lib/utils.bash index 635fe6a4..cecfdec6 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -422,7 +422,7 @@ initialize_or_update_repository() { local repository_path disable_plugin_short_name_repo="$(get_asdf_config_value "disable_plugin_short_name_repository")" - if [ "yes" == "$disable_plugin_short_name_repo" ]; then + if [ "yes" = "$disable_plugin_short_name_repo" ]; then printf "Short-name plugin repository is disabled\n" >&2 exit 1 fi diff --git a/scripts/checkstyle.py b/scripts/checkstyle.py index 35ad8a36..00f15f1f 100755 --- a/scripts/checkstyle.py +++ b/scripts/checkstyle.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 import re -import sys import os import argparse from pathlib import Path @@ -39,18 +38,23 @@ def utilGetStrs(line, m): # Before: printf '%s\\n' '^w^' # After: printf '%s\n' '^w^' -def noDoubleBackslashFixer(line: str, rule: Dict[str, str], m) -> str: +def noDoubleBackslashFixer(line: str, m) -> str: prestr, midstr, poststr = utilGetStrs(line, m) return f'{prestr}{midstr[1:]}{poststr}' # Before: $(pwd) # After: $PWD -def noPwdCapture(line: str, rule: Dict[str, str], m) -> str: +def noPwdCaptureFixer(line: str, m) -> str: prestr, midstr, poststr = utilGetStrs(line, m) return f'{prestr}$PWD{poststr}' +def noTestDoubleEqualsFixer(line: str, m) -> str: + prestr, midstr, poststr = utilGetStrs(line, m) + + return f'{prestr}={poststr}' + def lintfile(filepath: Path, rules: List[Dict[str, str]], options: Dict[str, Any]): content_arr = filepath.read_text().split('\n') @@ -72,7 +76,7 @@ def lintfile(filepath: Path, rules: List[Dict[str, str]], options: Dict[str, Any print() if options['fix']: - content_arr[line_i] = rule['fixerFn'](line, rule, m) + content_arr[line_i] = rule['fixerFn'](line, m) rule['found'] += 1 @@ -100,7 +104,7 @@ def main(): 'name': 'no-pwd-capture', 'regex': '(?P\\$\\(pwd\\))', 'reason': '$PWD is essentially equivalent to $(pwd) without the overhead of a subshell', - 'fixerFn': noPwdCapture, + 'fixerFn': noPwdCaptureFixer, 'testPositiveMatches': [ '$(pwd)' ], @@ -109,6 +113,23 @@ def main(): ], 'found': 0 }, + { + 'name': 'no-test-double-equals', + 'regex': '(?==).*?\\]', + 'reason': 'Although it is valid Bash, it reduces consistency and copy-paste-ability', + 'fixerFn': noTestDoubleEqualsFixer, + 'testPositiveMatches': [ + '[ a == b ]', + ], + 'testNegativeMatches': [ + '[ a = b ]', + '[[ a = b ]]', + '[[ a == b ]]', + '[ a = b ] || [[ a == b ]]', + '[[ a = b ]] || [[ a == b ]]' + ], + 'found': 0 + } ] parser = argparse.ArgumentParser() @@ -132,6 +153,7 @@ def main(): print(f'{c.MAGENTA}{rule["name"]}{c.RESET}: Failed {c.YELLOW}negative{c.RESET} test:') print(f'=> {negativeMatch}') print() + print('Done.') return options = { diff --git a/test/asdf_nu.bats b/test/asdf_nu.bats index c9ad085b..21c0803a 100644 --- a/test/asdf_nu.bats +++ b/test/asdf_nu.bats @@ -28,7 +28,7 @@ cleaned_path() { [ "$?" -eq 0 ] output=$(echo "$result" | grep "asdf") - [ "$output" == $PWD ] + [ "$output" = $PWD ] } @test "adds asdf dirs to PATH" { @@ -45,9 +45,9 @@ cleaned_path() { ") [ "$?" -eq 0 ] output_bin=$(echo "$result" | grep "asdf/bin") - [ "$output_bin" == "$PWD/bin" ] + [ "$output_bin" = "$PWD/bin" ] output_shims=$(echo "$result" | grep "/shims") - [ "$output_shims" == "$HOME/.asdf/shims" ] + [ "$output_shims" = "$HOME/.asdf/shims" ] } @test "does not add paths to PATH more than once" { diff --git a/test/banned_commands.bats b/test/banned_commands.bats index 729c7d99..b947e189 100644 --- a/test/banned_commands.bats +++ b/test/banned_commands.bats @@ -79,7 +79,7 @@ teardown() { fi [ "$status" -eq 1 ] - [ "" == "$output" ] + [ "" = "$output" ] done for cmd in "${banned_commands_regex[@]}"; do @@ -96,6 +96,6 @@ teardown() { fi [ "$status" -eq 1 ] - [ "" == "$output" ] + [ "" = "$output" ] done } diff --git a/test/help_command.bats b/test/help_command.bats index 3837732b..16b580a9 100644 --- a/test/help_command.bats +++ b/test/help_command.bats @@ -57,7 +57,7 @@ EOF run asdf help "sunny" [ "$status" -eq 1 ] - [ "$output" == "No plugin named sunny" ] + [ "$output" = "No plugin named sunny" ] } @test "help should fail when plugin doesn't have documentation callback" { @@ -65,7 +65,7 @@ EOF run asdf help "legacy-dummy" [ "$status" -eq 1 ] - [ "$output" == "No documentation for plugin legacy-dummy" ] + [ "$output" = "No documentation for plugin legacy-dummy" ] } @test "help should show asdf help when no plugin name is provided" { diff --git a/test/install_command.bats b/test/install_command.bats index f7816f2a..21a7f466 100644 --- a/test/install_command.bats +++ b/test/install_command.bats @@ -123,7 +123,7 @@ teardown() { # execute the generated shim run $ASDF_DIR/shims/dummy world hello [ "$status" -eq 0 ] - [ "$output" == "This is Dummy 1.0.0! hello world" ] + [ "$output" = "This is Dummy 1.0.0! hello world" ] } @test "install_command fails when tool is specified but no version of the tool is configured" { @@ -180,7 +180,7 @@ teardown() { run asdf install # execute the generated shim - [ "$($ASDF_DIR/shims/dummy world hello)" == "This is Dummy 1.0.0! hello world" ] + [ "$($ASDF_DIR/shims/dummy world hello)" = "This is Dummy 1.0.0! hello world" ] [ "$status" -eq 0 ] } @@ -208,7 +208,7 @@ pre_asdf_install_dummy = echo will install dummy $1 EOM run asdf install dummy 1.0.0 - [ "$output" == "will install dummy 1.0.0" ] + [ "$output" = "will install dummy 1.0.0" ] } @test "install command executes configured post plugin install hook" { @@ -217,7 +217,7 @@ post_asdf_install_dummy = echo HEY $version FROM $plugin_name EOM run asdf install dummy 1.0.0 - [ "$output" == "HEY 1.0.0 FROM dummy" ] + [ "$output" = "HEY 1.0.0 FROM dummy" ] } @test "install command without arguments installs versions from legacy files" { @@ -226,7 +226,7 @@ EOM cd $PROJECT_DIR run asdf install [ "$status" -eq 0 ] - [ "$output" == "" ] + [ "$output" = "" ] [ -f $ASDF_DIR/installs/dummy/1.2.0/version ] } @@ -239,7 +239,7 @@ EOM run asdf install [ "$status" -eq 0 ] - [ "$output" == "" ] + [ "$output" = "" ] [ -f $ASDF_DIR/installs/dummy/1.2.0/version ] } @@ -284,5 +284,5 @@ EOM [ "$status" -eq 1 ] [ ! -d $ASDF_DIR/downloads/dummy-broken/1.1.0 ] [ ! -d $ASDF_DIR/installs/dummy-broken/1.1.0 ] - [ "$output" == "Download failed!" ] + [ "$output" = "Download failed!" ] } diff --git a/test/latest_command.bats b/test/latest_command.bats index 8e01ce80..d46a8cb6 100644 --- a/test/latest_command.bats +++ b/test/latest_command.bats @@ -17,19 +17,19 @@ teardown() { #################################################### @test "[latest_command - dummy_plugin] shows latest stable version" { run asdf latest dummy - [ "$(echo "2.0.0")" == "$output" ] + [ "$(echo "2.0.0")" = "$output" ] [ "$status" -eq 0 ] } @test "[latest_command - dummy_plugin] shows latest stable version that matches the given string" { run asdf latest dummy 1 - [ "$(echo "1.1.0")" == "$output" ] + [ "$(echo "1.1.0")" = "$output" ] [ "$status" -eq 0 ] } @test "[latest_command - dummy_plugin] an invalid version should return an error" { run asdf latest dummy 3 - [ "$(echo "No compatible versions available (dummy 3)")" == "$output" ] + [ "$(echo "No compatible versions available (dummy 3)")" = "$output" ] [ "$status" -eq 1 ] } @@ -40,7 +40,7 @@ teardown() { run asdf latest legacy-dummy echo "status: $status" echo "output: $output" - [ "$(echo "5.1.0")" == "$output" ] + [ "$(echo "5.1.0")" = "$output" ] [ "$status" -eq 0 ] } @@ -48,7 +48,7 @@ teardown() { run asdf latest legacy-dummy 1 echo "status: $status" echo "output: $output" - [ "$(echo "1.1.0")" == "$output" ] + [ "$(echo "1.1.0")" = "$output" ] [ "$status" -eq 0 ] } @@ -64,7 +64,7 @@ teardown() { run asdf latest legacy-dummy 4 echo "status: $status" echo "output: $output" - [ "$(echo "4.0.0")" == "$output" ] + [ "$(echo "4.0.0")" = "$output" ] [ "$status" -eq 0 ] } @@ -72,7 +72,7 @@ teardown() { run asdf latest legacy-dummy 5 echo "status: $status" echo "output: $output" - [ "$(echo "5.1.0")" == "$output" ] + [ "$(echo "5.1.0")" = "$output" ] [ "$status" -eq 0 ] } @@ -80,7 +80,7 @@ teardown() { run asdf latest legacy-dummy 6 echo "status: $status" echo "output: $output" - [ "$(echo "No compatible versions available (legacy-dummy 6)")" == "$output" ] + [ "$(echo "No compatible versions available (legacy-dummy 6)")" = "$output" ] [ "$status" -eq 1 ] } @@ -92,12 +92,12 @@ teardown() { 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" ] + [ "$(echo -e "dummy\t2.0.0\tinstalled\nlegacy-dummy\t5.1.0\tmissing\n")" = "$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" ] + [ "$(echo -e "dummy\t2.0.0\tmissing\nlegacy-dummy\t5.1.0\tmissing\n")" = "$output" ] [ "$status" -eq 0 ] } diff --git a/test/list_command.bats b/test/list_command.bats index c7b8f283..2f25f9ee 100644 --- a/test/list_command.bats +++ b/test/list_command.bats @@ -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" ] + [ "$(echo -e " 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" ] + [ "$(echo -e " 1.0\n 1.1")" = "$output" ] [ "$status" -eq 0 ] } @@ -71,25 +71,25 @@ teardown() { run asdf install dummy 1.0 run asdf install dummy 1.1 run asdf list dummy 2 - [ "$(echo "No compatible versions installed (dummy 2)")" == "$output" ] + [ "$(echo "No compatible versions installed (dummy 2)")" = "$output" ] [ "$status" -eq 1 ] } @test "list_all_command lists available versions" { run asdf list-all dummy - [ "$(echo -e "1.0.0\n1.1.0\n2.0.0")" == "$output" ] + [ "$(echo -e "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" ] + [ "$(echo -e "1.0.0\n1.1.0")" = "$output" ] [ "$status" -eq 0 ] } @test "list_all_command with an invalid version should return an error" { run asdf list-all dummy 3 - [ "$(echo "No compatible versions available (dummy 3)")" == "$output" ] + [ "$(echo "No compatible versions available (dummy 3)")" = "$output" ] [ "$status" -eq 1 ] } diff --git a/test/reshim_command.bats b/test/reshim_command.bats index a6f90194..406c072d 100644 --- a/test/reshim_command.bats +++ b/test/reshim_command.bats @@ -127,7 +127,7 @@ pre_asdf_reshim_dummy = echo RESHIM EOM run asdf reshim dummy 1.0 - [ "$output" == "RESHIM" ] + [ "$output" = "RESHIM" ] } @test "reshim command executes configured post hook" { @@ -138,7 +138,7 @@ post_asdf_reshim_dummy = echo RESHIM EOM run asdf reshim dummy 1.0 - [ "$output" == "RESHIM" ] + [ "$output" = "RESHIM" ] } # Fixes https://github.com/asdf-vm/asdf/issues/1115 diff --git a/test/shim_env_command.bats b/test/shim_env_command.bats index cff29d4b..82c09f7b 100644 --- a/test/shim_env_command.bats +++ b/test/shim_env_command.bats @@ -30,7 +30,7 @@ teardown() { run asdf env dummy which dummy [ "$status" -eq 0 ] - [ "$output" == "$ASDF_DIR/installs/dummy/1.0/bin/dummy" ] + [ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/dummy" ] } @test "asdf env should execute under plugin custom environment used for a shim" { @@ -58,11 +58,11 @@ teardown() { [ "$status" -eq 0 ] run grep 'FOO=bar' <(echo $output) - [ "$output" == "" ] + [ "$output" = "" ] [ "$status" -eq 1 ] run asdf env dummy which dummy - [ "$output" == "$ASDF_DIR/shims/dummy" ] + [ "$output" = "$ASDF_DIR/shims/dummy" ] [ "$status" -eq 0 ] } @@ -79,5 +79,5 @@ teardown() { # Should not contain duplicate colon run grep '::' <(echo "$path_line") - [ "$duplicate_colon" == "" ] + [ "$duplicate_colon" = "" ] } diff --git a/test/shim_exec.bats b/test/shim_exec.bats index 0365b7cf..f0568493 100644 --- a/test/shim_exec.bats +++ b/test/shim_exec.bats @@ -29,7 +29,7 @@ teardown() { run asdf install run asdf exec dummy world hello - [ "$output" == "This is Dummy 1.0! hello world" ] + [ "$output" = "This is Dummy 1.0! hello world" ] [ "$status" -eq 0 ] } @@ -39,11 +39,11 @@ teardown() { path=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g") run env PATH=$path which dummy - [ "$output" == "" ] + [ "$output" = "" ] [ "$status" -eq 1 ] run env PATH=$path asdf exec dummy world hello - [ "$output" == "This is Dummy 1.0! hello world" ] + [ "$output" = "This is Dummy 1.0! hello world" ] [ "$status" -eq 0 ] } @@ -52,7 +52,7 @@ teardown() { run asdf install run $ASDF_DIR/shims/dummy world hello - [ "$output" == "This is Dummy 1.0! hello world" ] + [ "$output" = "This is Dummy 1.0! hello world" ] [ "$status" -eq 0 ] } @@ -66,7 +66,7 @@ teardown() { run asdf reshim dummy 1.0 run echo $(echo hello | $ASDF_DIR/shims/upper) - [ "$output" == "HELLO" ] + [ "$output" = "HELLO" ] [ "$status" -eq 0 ] } @@ -166,12 +166,12 @@ teardown() { cd $PROJECT_DIR/A run $ASDF_DIR/shims/dummy world hello - [ "$output" == "This is Dummy 1.0! hello world" ] + [ "$output" = "This is Dummy 1.0! hello world" ] [ "$status" -eq 0 ] cd $PROJECT_DIR/B run $ASDF_DIR/shims/dummy world hello - [ "$output" == "This is Mummy 3.0! hello world" ] + [ "$output" = "This is Mummy 3.0! hello world" ] [ "$status" -eq 0 ] } @@ -188,7 +188,7 @@ teardown() { echo "dummy 1.0" >>$PROJECT_DIR/.tool-versions run $ASDF_DIR/shims/dummy world hello - [ "$output" == "This is Mummy 3.0! hello world" ] + [ "$output" = "This is Mummy 3.0! hello world" ] [ "$status" -eq 0 ] } @@ -202,7 +202,7 @@ teardown() { chmod +x $PROJECT_DIR/foo/dummy run env PATH=$PATH:$PROJECT_DIR/foo $ASDF_DIR/shims/dummy hello - [ "$output" == "System" ] + [ "$output" = "System" ] } @test "shim exec should use path executable when specified version path:" { @@ -217,7 +217,7 @@ teardown() { echo "dummy path:$CUSTOM_DUMMY_PATH" >$PROJECT_DIR/.tool-versions run $ASDF_DIR/shims/dummy hello - [ "$output" == "System" ] + [ "$output" = "System" ] } @test "shim exec should execute system if set first" { @@ -231,7 +231,7 @@ teardown() { chmod +x $PROJECT_DIR/foo/dummy run env PATH=$PATH:$PROJECT_DIR/foo $ASDF_DIR/shims/dummy hello - [ "$output" == "System" ] + [ "$output" = "System" ] } @test "shim exec should use custom exec-env for tool" { @@ -244,7 +244,7 @@ teardown() { echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions run $ASDF_DIR/shims/foo - [ "$output" == "sourced custom" ] + [ "$output" = "sourced custom" ] } @test "shim exec with custom exec-env using ASDF_INSTALL_PATH" { @@ -257,7 +257,7 @@ teardown() { echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions run $ASDF_DIR/shims/foo - [ "$output" == "$ASDF_DIR/installs/dummy/2.0.0/foo custom" ] + [ "$output" = "$ASDF_DIR/installs/dummy/2.0.0/foo custom" ] } @test "shim exec doest not use custom exec-env for system version" { @@ -275,7 +275,7 @@ teardown() { chmod +x $PROJECT_DIR/sys/foo run env PATH=$PATH:$PROJECT_DIR/sys $ASDF_DIR/shims/foo - [ "$output" == "x System" ] + [ "$output" = "x System" ] } @test "shim exec should prepend the plugin paths on execution" { @@ -289,7 +289,7 @@ teardown() { echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions run $ASDF_DIR/shims/foo - [ "$output" == "$ASDF_DIR/installs/dummy/2.0.0/bin/dummy" ] + [ "$output" = "$ASDF_DIR/installs/dummy/2.0.0/bin/dummy" ] } @test "shim exec should be able to find other shims in path" { @@ -314,10 +314,10 @@ teardown() { run asdf reshim run $ASDF_DIR/shims/foo - [ "$output" == "$ASDF_DIR/installs/dummy/2.0.0/bin/dummy" ] + [ "$output" = "$ASDF_DIR/installs/dummy/2.0.0/bin/dummy" ] run $ASDF_DIR/shims/bar - [ "$output" == "$ASDF_DIR/shims/gummy" ] + [ "$output" = "$ASDF_DIR/shims/gummy" ] } @test "shim exec should remove shim_path from path on system version execution" { @@ -331,7 +331,7 @@ teardown() { run env PATH=$PATH:$PROJECT_DIR/sys $ASDF_DIR/shims/dummy echo $status $output - [ "$output" == "$ASDF_DIR/shims/dummy" ] + [ "$output" = "$ASDF_DIR/shims/dummy" ] } @test "shim exec can take version from legacy file if configured" { @@ -341,13 +341,13 @@ teardown() { echo "2.0.0" >$PROJECT_DIR/.dummy-version run $ASDF_DIR/shims/dummy world hello - [ "$output" == "This is Dummy 2.0.0! hello world" ] + [ "$output" = "This is Dummy 2.0.0! hello world" ] } @test "shim exec can take version from environment variable" { run asdf install dummy 2.0.0 run env ASDF_DUMMY_VERSION=2.0.0 $ASDF_DIR/shims/dummy world hello - [ "$output" == "This is Dummy 2.0.0! hello world" ] + [ "$output" = "This is Dummy 2.0.0! hello world" ] } @test "shim exec uses plugin list-bin-paths" { @@ -367,7 +367,7 @@ teardown() { run asdf reshim dummy 1.0 run $ASDF_DIR/shims/foo - [ "$output" == "CUSTOM" ] + [ "$output" = "CUSTOM" ] } @test "shim exec uses plugin custom exec-path hook" { @@ -386,7 +386,7 @@ teardown() { echo "dummy 1.0" >$PROJECT_DIR/.tool-versions run $ASDF_DIR/shims/dummy - [ "$output" == "CUSTOM" ] + [ "$output" = "CUSTOM" ] } @test "shim exec uses plugin custom exec-path hook that defaults" { @@ -400,7 +400,7 @@ teardown() { echo "dummy 1.0" >$PROJECT_DIR/.tool-versions run $ASDF_DIR/shims/dummy - [ "$output" == "This is Dummy 1.0!" ] + [ "$output" = "This is Dummy 1.0!" ] } @test "shim exec executes configured pre-hook" { @@ -431,7 +431,7 @@ pre_dummy_dummy = pre $1 no $plugin_name $2 EOM run env PATH=$PATH:$HOME/hook $ASDF_DIR/shims/dummy hello world - [ "$output" == "hello no dummy world" ] + [ "$output" = "hello no dummy world" ] [ "$status" -eq 1 ] } @@ -444,6 +444,6 @@ EOM run asdf exec dummy world hello echo $output - [ "$output" == "This is Dummy 1.0! hello world" ] + [ "$output" = "This is Dummy 1.0! hello world" ] [ "$status" -eq 0 ] } diff --git a/test/uninstall_command.bats b/test/uninstall_command.bats index 4dad8a4e..14c6c90b 100644 --- a/test/uninstall_command.bats +++ b/test/uninstall_command.bats @@ -16,7 +16,7 @@ teardown() { @test "uninstall_command should fail when no such version is installed" { run asdf uninstall dummy 3.14 - [ "$output" == "No such version" ] + [ "$output" = "No such version" ] [ "$status" -eq 1 ] } @@ -35,7 +35,7 @@ teardown() { echo "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" ] + [ "$output" = "custom uninstall" ] [ "$status" -eq 0 ] } @@ -90,7 +90,7 @@ EOM run asdf install dummy 1.0.0 run asdf uninstall dummy 1.0.0 - [ "$output" == "will uninstall dummy 1.0.0" ] + [ "$output" = "will uninstall dummy 1.0.0" ] } @test "uninstall command executes configured post hook" { @@ -101,5 +101,5 @@ EOM run asdf install dummy 1.0.0 run asdf uninstall dummy 1.0.0 echo $output - [ "$output" == "removed dummy 1.0.0" ] + [ "$output" = "removed dummy 1.0.0" ] } diff --git a/test/update_command.bats b/test/update_command.bats index dabe69da..17fd0462 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" ] + [ "$(echo -e "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" ] + [ "$(echo -e "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 e750430b..4e12014c 100644 --- a/test/utils.bats +++ b/test/utils.bats @@ -113,7 +113,7 @@ teardown() { echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy [ "$status" -eq 0 ] - [ "$output" == "0.1.0" ] + [ "$output" = "0.1.0" ] } @test "parse_asdf_version_file should output path on project with spaces" { @@ -123,21 +123,21 @@ teardown() { echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions" run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy [ "$status" -eq 0 ] - [ "$output" == "0.1.0" ] + [ "$output" = "0.1.0" ] } @test "parse_asdf_version_file should output path version with spaces" { echo "dummy path:/some/dummy path" >$PROJECT_DIR/.tool-versions run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy [ "$status" -eq 0 ] - [ "$output" == "path:/some/dummy path" ] + [ "$output" = "path:/some/dummy path" ] } @test "parse_asdf_version_file should output path version with tilda" { echo "dummy path:~/some/dummy path" >$PROJECT_DIR/.tool-versions run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy [ "$status" -eq 0 ] - [ "$output" == "path:$HOME/some/dummy path" ] + [ "$output" = "path:$HOME/some/dummy path" ] } @test "find_versions should return .tool-versions if legacy is disabled" { diff --git a/test/which_command.bats b/test/which_command.bats index 8b4ef72c..f38ddd36 100644 --- a/test/which_command.bats +++ b/test/which_command.bats @@ -30,7 +30,7 @@ teardown() { run asdf which "sunny" [ "$status" -eq 1 ] - [ "$output" == "unknown command: sunny. Perhaps you have to reshim?" ] + [ "$output" = "unknown command: sunny. Perhaps you have to reshim?" ] } @test "which should show dummy 1.0 other binary" { @@ -55,7 +55,7 @@ teardown() { run env PATH=$PATH:$PROJECT_DIR/sys asdf which "dummy" [ "$status" -eq 0 ] - [ "$output" == "$PROJECT_DIR/sys/dummy" ] + [ "$output" = "$PROJECT_DIR/sys/dummy" ] } @test "which report when missing executable on system version" { @@ -64,7 +64,7 @@ teardown() { run asdf which "dummy" [ "$status" -eq 1 ] - [ "$output" == "No dummy executable found for dummy system" ] + [ "$output" = "No dummy executable found for dummy system" ] } @test "which should inform when no binary is found" { @@ -72,7 +72,7 @@ teardown() { run asdf which "bazbat" [ "$status" -eq 1 ] - [ "$output" == "unknown command: bazbat. Perhaps you have to reshim?" ] + [ "$output" = "unknown command: bazbat. Perhaps you have to reshim?" ] } @test "which should use path returned by exec-path when present" { @@ -104,5 +104,5 @@ teardown() { run env PATH=$PATH:$ASDF_DIR/shims asdf which dummy [ "$status" -eq 1 ] - [ "$output" == "No dummy executable found for dummy 1.0" ] + [ "$output" = "No dummy executable found for dummy 1.0" ] }