From 407a6696c0739f5e368543c4fc1b14e41458f177 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Sun, 22 Jan 2023 01:20:23 -0800 Subject: [PATCH] chore: fix ShellCheck errors in tests (#1433) --- test/asdf_elvish.bats | 17 +++++++++-------- test/current_command.bats | 4 ++-- test/install_command.bats | 2 +- test/remove_command.bats | 2 +- test/shim_exec.bats | 4 ++-- test/version_commands.bats | 2 +- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/test/asdf_elvish.bats b/test/asdf_elvish.bats index 4a9338c8..a0c61c72 100644 --- a/test/asdf_elvish.bats +++ b/test/asdf_elvish.bats @@ -3,16 +3,17 @@ load test_helpers setup() { - export XDG_CONFIG_HOME= XDG_DATA_HOME= XDG_DATA_DIRS= + export XDG_CONFIG_HOME= + export XDG_DATA_HOME= + export XDG_DATA_DIRS= - local version= - version=$(elvish -version) + local ver_major= + local ver_minor= + local ver_patch= + IFS='.' read -r ver_major ver_minor ver_patch <<<"$(elvish -version)" - local ver_major= ver_minor= ver_patch= - IFS='.' read -r ver_major ver_minor ver_patch <<<"$version" - - if ((ver_major == 0 && ver_minor <= 17)); then - skip "Elvish version is not at least 0.17" + if ((ver_major == 0 && ver_minor < 18)); then + skip "Elvish version is not at least 0.18. Found ${ver_major}.${ver_minor}.${ver_patch}" fi } diff --git a/test/current_command.bats b/test/current_command.bats index 29358b97..6451e5e4 100755 --- a/test/current_command.bats +++ b/test/current_command.bats @@ -134,8 +134,8 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions" } @test "current should handle comments" { - cd $PROJECT_DIR - echo "dummy 1.2.0 # this is a comment" >>$PROJECT_DIR/.tool-versions + cd "$PROJECT_DIR" + echo "dummy 1.2.0 # this is a comment" >>"$PROJECT_DIR/.tool-versions" expected="dummy 1.2.0 $PROJECT_DIR/.tool-versions" run asdf current "dummy" diff --git a/test/install_command.bats b/test/install_command.bats index 21a7f466..d2a4962d 100644 --- a/test/install_command.bats +++ b/test/install_command.bats @@ -95,7 +95,7 @@ teardown() { run grep "asdf-plugin: dummy 1.0.0" $ASDF_DIR/shims/dummy [ "$status" -eq 0 ] - run grep "# asdf-plugin: dummy 1.0.0"$'\n'"# asdf-plugin: dummy 1.1.0" $ASDF_DIR/shims/dummy + run grep "# asdf-plugin: dummy 1.0.0"$'\n'"# asdf-plugin: dummy 1.1.0" "$ASDF_DIR/shims/dummy" [ "$status" -eq 0 ] lines_count=$(grep "asdf-plugin: dummy 1.1.0" $ASDF_DIR/shims/dummy | wc -l) diff --git a/test/remove_command.bats b/test/remove_command.bats index f7a25b8b..49503a07 100644 --- a/test/remove_command.bats +++ b/test/remove_command.bats @@ -57,7 +57,7 @@ teardown() { run asdf install dummy 1.0 # make an unrelated shim - echo "# asdf-plugin: gummy" >$ASDF_DIR/shims/gummy + echo "# asdf-plugin: gummy" >"$ASDF_DIR/shims/gummy" run asdf plugin-remove dummy [ "$status" -eq 0 ] diff --git a/test/shim_exec.bats b/test/shim_exec.bats index f0568493..cdc9fc2d 100644 --- a/test/shim_exec.bats +++ b/test/shim_exec.bats @@ -394,8 +394,8 @@ teardown() { exec_path="$ASDF_DIR/plugins/dummy/bin/exec-path" - echo 'echo $3 # always same path' >$exec_path - chmod +x $exec_path + echo 'echo $3 # always same path' >"$exec_path" + chmod +x "$exec_path" echo "dummy 1.0" >$PROJECT_DIR/.tool-versions diff --git a/test/version_commands.bats b/test/version_commands.bats index 01b09f9f..dd79698a 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -115,7 +115,7 @@ teardown() { run asdf local "dummy" "1.1.0" [ "$status" -eq 0 ] - [ "$(ls $PROJECT_DIR/.tool-versions* | wc -l)" -eq 1 ] + [ "$(ls "$PROJECT_DIR/.tool-versions"* | wc -l)" -eq 1 ] } @test "local should overwrite the existing version if it's set" {