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 <Stratus3D@users.noreply.github.com>
This commit is contained in:
Edwin Kofler 2023-01-14 05:18:44 -08:00 committed by GitHub
parent 27c8a101e5
commit d81b81f9de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 105 additions and 83 deletions

View File

@ -129,7 +129,7 @@ latest_command() {
local query=$2 local query=$2
local plugin_path local plugin_path
if [ "$plugin_name" == "--all" ]; then if [ "$plugin_name" = "--all" ]; then
latest_all latest_all
fi fi

View File

@ -422,7 +422,7 @@ initialize_or_update_repository() {
local repository_path local repository_path
disable_plugin_short_name_repo="$(get_asdf_config_value "disable_plugin_short_name_repository")" 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 printf "Short-name plugin repository is disabled\n" >&2
exit 1 exit 1
fi fi

View File

@ -1,6 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import re import re
import sys
import os import os
import argparse import argparse
from pathlib import Path from pathlib import Path
@ -39,18 +38,23 @@ def utilGetStrs(line, m):
# Before: printf '%s\\n' '^w^' # Before: printf '%s\\n' '^w^'
# After: 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) prestr, midstr, poststr = utilGetStrs(line, m)
return f'{prestr}{midstr[1:]}{poststr}' return f'{prestr}{midstr[1:]}{poststr}'
# Before: $(pwd) # Before: $(pwd)
# After: $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) prestr, midstr, poststr = utilGetStrs(line, m)
return f'{prestr}$PWD{poststr}' 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]): def lintfile(filepath: Path, rules: List[Dict[str, str]], options: Dict[str, Any]):
content_arr = filepath.read_text().split('\n') 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() print()
if options['fix']: if options['fix']:
content_arr[line_i] = rule['fixerFn'](line, rule, m) content_arr[line_i] = rule['fixerFn'](line, m)
rule['found'] += 1 rule['found'] += 1
@ -100,7 +104,7 @@ def main():
'name': 'no-pwd-capture', 'name': 'no-pwd-capture',
'regex': '(?P<match>\\$\\(pwd\\))', 'regex': '(?P<match>\\$\\(pwd\\))',
'reason': '$PWD is essentially equivalent to $(pwd) without the overhead of a subshell', 'reason': '$PWD is essentially equivalent to $(pwd) without the overhead of a subshell',
'fixerFn': noPwdCapture, 'fixerFn': noPwdCaptureFixer,
'testPositiveMatches': [ 'testPositiveMatches': [
'$(pwd)' '$(pwd)'
], ],
@ -109,6 +113,23 @@ def main():
], ],
'found': 0 'found': 0
}, },
{
'name': 'no-test-double-equals',
'regex': '(?<!\\[)\\[[^[]*?(?P<match>==).*?\\]',
'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() 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'{c.MAGENTA}{rule["name"]}{c.RESET}: Failed {c.YELLOW}negative{c.RESET} test:')
print(f'=> {negativeMatch}') print(f'=> {negativeMatch}')
print() print()
print('Done.')
return return
options = { options = {

View File

@ -28,7 +28,7 @@ cleaned_path() {
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
output=$(echo "$result" | grep "asdf") output=$(echo "$result" | grep "asdf")
[ "$output" == $PWD ] [ "$output" = $PWD ]
} }
@test "adds asdf dirs to PATH" { @test "adds asdf dirs to PATH" {
@ -45,9 +45,9 @@ cleaned_path() {
") ")
[ "$?" -eq 0 ] [ "$?" -eq 0 ]
output_bin=$(echo "$result" | grep "asdf/bin") output_bin=$(echo "$result" | grep "asdf/bin")
[ "$output_bin" == "$PWD/bin" ] [ "$output_bin" = "$PWD/bin" ]
output_shims=$(echo "$result" | grep "/shims") 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" { @test "does not add paths to PATH more than once" {

View File

@ -79,7 +79,7 @@ teardown() {
fi fi
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "" == "$output" ] [ "" = "$output" ]
done done
for cmd in "${banned_commands_regex[@]}"; do for cmd in "${banned_commands_regex[@]}"; do
@ -96,6 +96,6 @@ teardown() {
fi fi
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "" == "$output" ] [ "" = "$output" ]
done done
} }

View File

@ -57,7 +57,7 @@ EOF
run asdf help "sunny" run asdf help "sunny"
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "$output" == "No plugin named sunny" ] [ "$output" = "No plugin named sunny" ]
} }
@test "help should fail when plugin doesn't have documentation callback" { @test "help should fail when plugin doesn't have documentation callback" {
@ -65,7 +65,7 @@ EOF
run asdf help "legacy-dummy" run asdf help "legacy-dummy"
[ "$status" -eq 1 ] [ "$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" { @test "help should show asdf help when no plugin name is provided" {

View File

@ -123,7 +123,7 @@ teardown() {
# execute the generated shim # execute the generated shim
run $ASDF_DIR/shims/dummy world hello run $ASDF_DIR/shims/dummy world hello
[ "$status" -eq 0 ] [ "$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" { @test "install_command fails when tool is specified but no version of the tool is configured" {
@ -180,7 +180,7 @@ teardown() {
run asdf install run asdf install
# execute the generated shim # 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 ] [ "$status" -eq 0 ]
} }
@ -208,7 +208,7 @@ pre_asdf_install_dummy = echo will install dummy $1
EOM EOM
run asdf install dummy 1.0.0 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" { @test "install command executes configured post plugin install hook" {
@ -217,7 +217,7 @@ post_asdf_install_dummy = echo HEY $version FROM $plugin_name
EOM EOM
run asdf install dummy 1.0.0 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" { @test "install command without arguments installs versions from legacy files" {
@ -226,7 +226,7 @@ EOM
cd $PROJECT_DIR cd $PROJECT_DIR
run asdf install run asdf install
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "" ] [ "$output" = "" ]
[ -f $ASDF_DIR/installs/dummy/1.2.0/version ] [ -f $ASDF_DIR/installs/dummy/1.2.0/version ]
} }
@ -239,7 +239,7 @@ EOM
run asdf install run asdf install
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "" ] [ "$output" = "" ]
[ -f $ASDF_DIR/installs/dummy/1.2.0/version ] [ -f $ASDF_DIR/installs/dummy/1.2.0/version ]
} }
@ -284,5 +284,5 @@ EOM
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ ! -d $ASDF_DIR/downloads/dummy-broken/1.1.0 ] [ ! -d $ASDF_DIR/downloads/dummy-broken/1.1.0 ]
[ ! -d $ASDF_DIR/installs/dummy-broken/1.1.0 ] [ ! -d $ASDF_DIR/installs/dummy-broken/1.1.0 ]
[ "$output" == "Download failed!" ] [ "$output" = "Download failed!" ]
} }

View File

@ -17,19 +17,19 @@ teardown() {
#################################################### ####################################################
@test "[latest_command - dummy_plugin] shows latest stable version" { @test "[latest_command - dummy_plugin] shows latest stable version" {
run asdf latest dummy run asdf latest dummy
[ "$(echo "2.0.0")" == "$output" ] [ "$(echo "2.0.0")" = "$output" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "[latest_command - dummy_plugin] shows latest stable version that matches the given string" { @test "[latest_command - dummy_plugin] shows latest stable version that matches the given string" {
run asdf latest dummy 1 run asdf latest dummy 1
[ "$(echo "1.1.0")" == "$output" ] [ "$(echo "1.1.0")" = "$output" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@test "[latest_command - dummy_plugin] an invalid version should return an error" { @test "[latest_command - dummy_plugin] an invalid version should return an error" {
run asdf latest dummy 3 run asdf latest dummy 3
[ "$(echo "No compatible versions available (dummy 3)")" == "$output" ] [ "$(echo "No compatible versions available (dummy 3)")" = "$output" ]
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@ -40,7 +40,7 @@ teardown() {
run asdf latest legacy-dummy run asdf latest legacy-dummy
echo "status: $status" echo "status: $status"
echo "output: $output" echo "output: $output"
[ "$(echo "5.1.0")" == "$output" ] [ "$(echo "5.1.0")" = "$output" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -48,7 +48,7 @@ teardown() {
run asdf latest legacy-dummy 1 run asdf latest legacy-dummy 1
echo "status: $status" echo "status: $status"
echo "output: $output" echo "output: $output"
[ "$(echo "1.1.0")" == "$output" ] [ "$(echo "1.1.0")" = "$output" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -64,7 +64,7 @@ teardown() {
run asdf latest legacy-dummy 4 run asdf latest legacy-dummy 4
echo "status: $status" echo "status: $status"
echo "output: $output" echo "output: $output"
[ "$(echo "4.0.0")" == "$output" ] [ "$(echo "4.0.0")" = "$output" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -72,7 +72,7 @@ teardown() {
run asdf latest legacy-dummy 5 run asdf latest legacy-dummy 5
echo "status: $status" echo "status: $status"
echo "output: $output" echo "output: $output"
[ "$(echo "5.1.0")" == "$output" ] [ "$(echo "5.1.0")" = "$output" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -80,7 +80,7 @@ teardown() {
run asdf latest legacy-dummy 6 run asdf latest legacy-dummy 6
echo "status: $status" echo "status: $status"
echo "output: $output" echo "output: $output"
[ "$(echo "No compatible versions available (legacy-dummy 6)")" == "$output" ] [ "$(echo "No compatible versions available (legacy-dummy 6)")" = "$output" ]
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@ -92,12 +92,12 @@ teardown() {
run asdf install legacy-dummy 4.0.0 run asdf install legacy-dummy 4.0.0
run asdf latest --all run asdf latest --all
echo "output $output" 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 ] [ "$status" -eq 0 ]
} }
@test "[latest_command - all plugins] not installed plugin should return missing" { @test "[latest_command - all plugins] not installed plugin should return missing" {
run asdf latest --all 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 ] [ "$status" -eq 0 ]
} }

View File

@ -54,7 +54,7 @@ teardown() {
run asdf install dummy 1.0.0 run asdf install dummy 1.0.0
run asdf install dummy 1.1.0 run asdf install dummy 1.1.0
run asdf list dummy 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 ] [ "$status" -eq 0 ]
} }
@ -63,7 +63,7 @@ teardown() {
run asdf install dummy 1.1 run asdf install dummy 1.1
run asdf install dummy 2.0 run asdf install dummy 2.0
run asdf list dummy 1 run asdf list dummy 1
[ "$(echo -e " 1.0\n 1.1")" == "$output" ] [ "$(echo -e " 1.0\n 1.1")" = "$output" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -71,25 +71,25 @@ teardown() {
run asdf install dummy 1.0 run asdf install dummy 1.0
run asdf install dummy 1.1 run asdf install dummy 1.1
run asdf list dummy 2 run asdf list dummy 2
[ "$(echo "No compatible versions installed (dummy 2)")" == "$output" ] [ "$(echo "No compatible versions installed (dummy 2)")" = "$output" ]
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@test "list_all_command lists available versions" { @test "list_all_command lists available versions" {
run asdf list-all dummy 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 ] [ "$status" -eq 0 ]
} }
@test "list_all_command with version filters available versions" { @test "list_all_command with version filters available versions" {
run asdf list-all dummy 1 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 ] [ "$status" -eq 0 ]
} }
@test "list_all_command with an invalid version should return an error" { @test "list_all_command with an invalid version should return an error" {
run asdf list-all dummy 3 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 ] [ "$status" -eq 1 ]
} }

View File

@ -127,7 +127,7 @@ pre_asdf_reshim_dummy = echo RESHIM
EOM EOM
run asdf reshim dummy 1.0 run asdf reshim dummy 1.0
[ "$output" == "RESHIM" ] [ "$output" = "RESHIM" ]
} }
@test "reshim command executes configured post hook" { @test "reshim command executes configured post hook" {
@ -138,7 +138,7 @@ post_asdf_reshim_dummy = echo RESHIM
EOM EOM
run asdf reshim dummy 1.0 run asdf reshim dummy 1.0
[ "$output" == "RESHIM" ] [ "$output" = "RESHIM" ]
} }
# Fixes https://github.com/asdf-vm/asdf/issues/1115 # Fixes https://github.com/asdf-vm/asdf/issues/1115

View File

@ -30,7 +30,7 @@ teardown() {
run asdf env dummy which dummy run asdf env dummy which dummy
[ "$status" -eq 0 ] [ "$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" { @test "asdf env should execute under plugin custom environment used for a shim" {
@ -58,11 +58,11 @@ teardown() {
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
run grep 'FOO=bar' <(echo $output) run grep 'FOO=bar' <(echo $output)
[ "$output" == "" ] [ "$output" = "" ]
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
run asdf env dummy which dummy run asdf env dummy which dummy
[ "$output" == "$ASDF_DIR/shims/dummy" ] [ "$output" = "$ASDF_DIR/shims/dummy" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -79,5 +79,5 @@ teardown() {
# Should not contain duplicate colon # Should not contain duplicate colon
run grep '::' <(echo "$path_line") run grep '::' <(echo "$path_line")
[ "$duplicate_colon" == "" ] [ "$duplicate_colon" = "" ]
} }

View File

@ -29,7 +29,7 @@ teardown() {
run asdf install run asdf install
run asdf exec dummy world hello 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 ] [ "$status" -eq 0 ]
} }
@ -39,11 +39,11 @@ teardown() {
path=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g") path=$(echo "$PATH" | sed -e "s|$(asdf_data_dir)/shims||g; s|::|:|g")
run env PATH=$path which dummy run env PATH=$path which dummy
[ "$output" == "" ] [ "$output" = "" ]
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
run env PATH=$path asdf exec dummy world hello 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 ] [ "$status" -eq 0 ]
} }
@ -52,7 +52,7 @@ teardown() {
run asdf install run asdf install
run $ASDF_DIR/shims/dummy world hello 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 ] [ "$status" -eq 0 ]
} }
@ -66,7 +66,7 @@ teardown() {
run asdf reshim dummy 1.0 run asdf reshim dummy 1.0
run echo $(echo hello | $ASDF_DIR/shims/upper) run echo $(echo hello | $ASDF_DIR/shims/upper)
[ "$output" == "HELLO" ] [ "$output" = "HELLO" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -166,12 +166,12 @@ teardown() {
cd $PROJECT_DIR/A cd $PROJECT_DIR/A
run $ASDF_DIR/shims/dummy world hello 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 ] [ "$status" -eq 0 ]
cd $PROJECT_DIR/B cd $PROJECT_DIR/B
run $ASDF_DIR/shims/dummy world hello 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 ] [ "$status" -eq 0 ]
} }
@ -188,7 +188,7 @@ teardown() {
echo "dummy 1.0" >>$PROJECT_DIR/.tool-versions echo "dummy 1.0" >>$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/dummy world hello 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 ] [ "$status" -eq 0 ]
} }
@ -202,7 +202,7 @@ teardown() {
chmod +x $PROJECT_DIR/foo/dummy chmod +x $PROJECT_DIR/foo/dummy
run env PATH=$PATH:$PROJECT_DIR/foo $ASDF_DIR/shims/dummy hello 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:<path>" { @test "shim exec should use path executable when specified version path:<path>" {
@ -217,7 +217,7 @@ teardown() {
echo "dummy path:$CUSTOM_DUMMY_PATH" >$PROJECT_DIR/.tool-versions echo "dummy path:$CUSTOM_DUMMY_PATH" >$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/dummy hello run $ASDF_DIR/shims/dummy hello
[ "$output" == "System" ] [ "$output" = "System" ]
} }
@test "shim exec should execute system if set first" { @test "shim exec should execute system if set first" {
@ -231,7 +231,7 @@ teardown() {
chmod +x $PROJECT_DIR/foo/dummy chmod +x $PROJECT_DIR/foo/dummy
run env PATH=$PATH:$PROJECT_DIR/foo $ASDF_DIR/shims/dummy hello 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" { @test "shim exec should use custom exec-env for tool" {
@ -244,7 +244,7 @@ teardown() {
echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/foo run $ASDF_DIR/shims/foo
[ "$output" == "sourced custom" ] [ "$output" = "sourced custom" ]
} }
@test "shim exec with custom exec-env using ASDF_INSTALL_PATH" { @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 echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/foo 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" { @test "shim exec doest not use custom exec-env for system version" {
@ -275,7 +275,7 @@ teardown() {
chmod +x $PROJECT_DIR/sys/foo chmod +x $PROJECT_DIR/sys/foo
run env PATH=$PATH:$PROJECT_DIR/sys $ASDF_DIR/shims/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" { @test "shim exec should prepend the plugin paths on execution" {
@ -289,7 +289,7 @@ teardown() {
echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions echo "dummy 2.0.0" >$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/foo 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" { @test "shim exec should be able to find other shims in path" {
@ -314,10 +314,10 @@ teardown() {
run asdf reshim run asdf reshim
run $ASDF_DIR/shims/foo 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 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" { @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 run env PATH=$PATH:$PROJECT_DIR/sys $ASDF_DIR/shims/dummy
echo $status $output echo $status $output
[ "$output" == "$ASDF_DIR/shims/dummy" ] [ "$output" = "$ASDF_DIR/shims/dummy" ]
} }
@test "shim exec can take version from legacy file if configured" { @test "shim exec can take version from legacy file if configured" {
@ -341,13 +341,13 @@ teardown() {
echo "2.0.0" >$PROJECT_DIR/.dummy-version echo "2.0.0" >$PROJECT_DIR/.dummy-version
run $ASDF_DIR/shims/dummy world hello 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" { @test "shim exec can take version from environment variable" {
run asdf install dummy 2.0.0 run asdf install dummy 2.0.0
run env ASDF_DUMMY_VERSION=2.0.0 $ASDF_DIR/shims/dummy world hello 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" { @test "shim exec uses plugin list-bin-paths" {
@ -367,7 +367,7 @@ teardown() {
run asdf reshim dummy 1.0 run asdf reshim dummy 1.0
run $ASDF_DIR/shims/foo run $ASDF_DIR/shims/foo
[ "$output" == "CUSTOM" ] [ "$output" = "CUSTOM" ]
} }
@test "shim exec uses plugin custom exec-path hook" { @test "shim exec uses plugin custom exec-path hook" {
@ -386,7 +386,7 @@ teardown() {
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/dummy run $ASDF_DIR/shims/dummy
[ "$output" == "CUSTOM" ] [ "$output" = "CUSTOM" ]
} }
@test "shim exec uses plugin custom exec-path hook that defaults" { @test "shim exec uses plugin custom exec-path hook that defaults" {
@ -400,7 +400,7 @@ teardown() {
echo "dummy 1.0" >$PROJECT_DIR/.tool-versions echo "dummy 1.0" >$PROJECT_DIR/.tool-versions
run $ASDF_DIR/shims/dummy run $ASDF_DIR/shims/dummy
[ "$output" == "This is Dummy 1.0!" ] [ "$output" = "This is Dummy 1.0!" ]
} }
@test "shim exec executes configured pre-hook" { @test "shim exec executes configured pre-hook" {
@ -431,7 +431,7 @@ pre_dummy_dummy = pre $1 no $plugin_name $2
EOM EOM
run env PATH=$PATH:$HOME/hook $ASDF_DIR/shims/dummy hello world 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 ] [ "$status" -eq 1 ]
} }
@ -444,6 +444,6 @@ EOM
run asdf exec dummy world hello run asdf exec dummy world hello
echo $output echo $output
[ "$output" == "This is Dummy 1.0! hello world" ] [ "$output" = "This is Dummy 1.0! hello world" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }

View File

@ -16,7 +16,7 @@ teardown() {
@test "uninstall_command should fail when no such version is installed" { @test "uninstall_command should fail when no such version is installed" {
run asdf uninstall dummy 3.14 run asdf uninstall dummy 3.14
[ "$output" == "No such version" ] [ "$output" = "No such version" ]
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
} }
@ -35,7 +35,7 @@ teardown() {
echo "echo custom uninstall" >$ASDF_DIR/plugins/dummy/bin/uninstall echo "echo custom uninstall" >$ASDF_DIR/plugins/dummy/bin/uninstall
chmod 755 $ASDF_DIR/plugins/dummy/bin/uninstall chmod 755 $ASDF_DIR/plugins/dummy/bin/uninstall
run asdf uninstall dummy 1.1.0 run asdf uninstall dummy 1.1.0
[ "$output" == "custom uninstall" ] [ "$output" = "custom uninstall" ]
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
} }
@ -90,7 +90,7 @@ EOM
run asdf install dummy 1.0.0 run asdf install dummy 1.0.0
run asdf uninstall 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" { @test "uninstall command executes configured post hook" {
@ -101,5 +101,5 @@ EOM
run asdf install dummy 1.0.0 run asdf install dummy 1.0.0
run asdf uninstall dummy 1.0.0 run asdf uninstall dummy 1.0.0
echo $output echo $output
[ "$output" == "removed dummy 1.0.0" ] [ "$output" = "removed dummy 1.0.0" ]
} }

View File

@ -61,14 +61,14 @@ teardown() {
touch $ASDF_DIR/asdf_updates_disabled touch $ASDF_DIR/asdf_updates_disabled
run asdf update run asdf update
[ "$status" -eq 42 ] [ "$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" { @test "asdf update is a noop for non-git repos" {
rm -rf $ASDF_DIR/.git/ rm -rf $ASDF_DIR/.git/
run asdf update run asdf update
[ "$status" -eq 42 ] [ "$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" { @test "asdf update fails with exit code 1" {

View File

@ -113,7 +113,7 @@ teardown() {
echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions echo "dummy 0.1.0" >$PROJECT_DIR/.tool-versions
run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "0.1.0" ] [ "$output" = "0.1.0" ]
} }
@test "parse_asdf_version_file should output path on project with spaces" { @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" echo "dummy 0.1.0" >"$PROJECT_DIR/.tool-versions"
run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy run parse_asdf_version_file "$PROJECT_DIR/.tool-versions" dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "0.1.0" ] [ "$output" = "0.1.0" ]
} }
@test "parse_asdf_version_file should output path version with spaces" { @test "parse_asdf_version_file should output path version with spaces" {
echo "dummy path:/some/dummy path" >$PROJECT_DIR/.tool-versions echo "dummy path:/some/dummy path" >$PROJECT_DIR/.tool-versions
run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "path:/some/dummy path" ] [ "$output" = "path:/some/dummy path" ]
} }
@test "parse_asdf_version_file should output path version with tilda" { @test "parse_asdf_version_file should output path version with tilda" {
echo "dummy path:~/some/dummy path" >$PROJECT_DIR/.tool-versions echo "dummy path:~/some/dummy path" >$PROJECT_DIR/.tool-versions
run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy run parse_asdf_version_file $PROJECT_DIR/.tool-versions dummy
[ "$status" -eq 0 ] [ "$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" { @test "find_versions should return .tool-versions if legacy is disabled" {

View File

@ -30,7 +30,7 @@ teardown() {
run asdf which "sunny" run asdf which "sunny"
[ "$status" -eq 1 ] [ "$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" { @test "which should show dummy 1.0 other binary" {
@ -55,7 +55,7 @@ teardown() {
run env PATH=$PATH:$PROJECT_DIR/sys asdf which "dummy" run env PATH=$PATH:$PROJECT_DIR/sys asdf which "dummy"
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ "$output" == "$PROJECT_DIR/sys/dummy" ] [ "$output" = "$PROJECT_DIR/sys/dummy" ]
} }
@test "which report when missing executable on system version" { @test "which report when missing executable on system version" {
@ -64,7 +64,7 @@ teardown() {
run asdf which "dummy" run asdf which "dummy"
[ "$status" -eq 1 ] [ "$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" { @test "which should inform when no binary is found" {
@ -72,7 +72,7 @@ teardown() {
run asdf which "bazbat" run asdf which "bazbat"
[ "$status" -eq 1 ] [ "$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" { @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 run env PATH=$PATH:$ASDF_DIR/shims asdf which dummy
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
[ "$output" == "No dummy executable found for dummy 1.0" ] [ "$output" = "No dummy executable found for dummy 1.0" ]
} }