diff --git a/tests/test_versions/test.sh b/tests/test_versions/test.sh index 1cd68c4018fcb02839c4d81efe416bab02b5fb24..e7fb4910f152fdcbc055b05c22dcdd650903b61b 100755 --- a/tests/test_versions/test.sh +++ b/tests/test_versions/test.sh @@ -50,7 +50,7 @@ function test_require { shift expected=$1 shift - args=$@ + args=("$@") if [ "$required" = "-" ]; then req_str="$MODULENAME" @@ -62,7 +62,7 @@ function test_require { echo "Running test case:" echo "Requested: $required" echo "Expected: $expected" - echo "Installed: $args" + echo "Installed: ${args[*]}" echo "============================================================" required=${required//+/\\+} @@ -70,7 +70,7 @@ function test_require { clean_vers - install_vers $args + install_vers "${args[@]}" echo "==========================================" echo "Running iocsh.bash -l cellMods -r $req_str" @@ -101,7 +101,7 @@ function format_output { shift expected=$1 shift - versions=$@ + versions=$* if [ "$result" = "0" ]; then result_str="\033[32mpassed\033[0m" @@ -109,7 +109,7 @@ function format_output { result_str="\033[31mfailed\033[0m" fi - printf "Test: %s\n" "$result_str" + printf "Test: %b\n" "$result_str" printf "requested: %-20s expected: %-20s\n" "$requested" "$expected" printf "Given versions: %s\n" "$versions" printf "============================================================\n" @@ -155,19 +155,24 @@ source "$ENV_SRC" &>/dev/null show_header +# TODO: Fix these silly shellcheck disables here. failed_tests=0 if [ -n "$COMMAND" ]; then + # shellcheck disable=2086 test_require $COMMAND &>>"$LOGFILE" result=$? [ "$result" = 0 ] || ((failed_tests++)) + # shellcheck disable=2086 format_output $result $COMMAND fi if [ -f "$TESTFILE" ]; then while read -r line; do + # shellcheck disable=2086 test_require $line &>>"$LOGFILE" result=$? [ "$result" = 0 ] || ((failed_tests++)) + # shellcheck disable=2086 format_output $result $line done < <(sed -e 's/[[:space:]]*#.*//; /^[[:space:]]*$/d' "$TESTFILE") fi