]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(test/test-functions): shellcheck for test/test-functions
authorHarald Hoyer <harald@redhat.com>
Tue, 30 Mar 2021 08:40:13 +0000 (10:40 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Tue, 30 Mar 2021 10:30:41 +0000 (12:30 +0200)
test/test-functions

index 53da5cc5b63bc5e1fc438d429b22b2c965d18739..73b4780097f0a12762f2fdf71b857e7efc963d94 100644 (file)
@@ -2,6 +2,7 @@
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 export PATH
 
+# shellcheck disable=SC1090
 [[ -e .testdir${TEST_RUN_ID:+-$TEST_RUN_ID} ]] && . .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
 if [[ -z $TESTDIR ]] || [[ ! -d $TESTDIR ]]; then
     TESTDIR=$(mktemp -d -p "/var/tmp" -t dracut-test.XXXXXX)
@@ -60,10 +61,10 @@ while (($# > 0)); do
         --all)
             check_root
             if ! test_check 2 &> test${TEST_RUN_ID:+-$TEST_RUN_ID}.log; then
-                echo -e "TEST: $TEST_DESCRIPTION " $COLOR_WARNING "[SKIPPED]" $COLOR_NORMAL
+                echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_WARNING" "[SKIPPED]" "$COLOR_NORMAL"
                 exit 0
             else
-                echo -e "TEST: $TEST_DESCRIPTION " $COLOR_SUCCESS "[STARTED]" $COLOR_NORMAL
+                echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_SUCCESS" "[STARTED]" "$COLOR_NORMAL"
             fi
             if [[ $V == "1" ]]; then
                 set -o pipefail
@@ -77,9 +78,10 @@ while (($# > 0)); do
                     rm -fr -- "$TESTDIR"
                     rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
                     exit $ret
-                ) < /dev/null 2>&1 | tee test${TEST_RUN_ID:+-$TEST_RUN_ID}.log
+                ) < /dev/null 2>&1 | tee "test${TEST_RUN_ID:+-$TEST_RUN_ID}.log"
             elif [[ $V == "2" ]]; then
                 set -o pipefail
+                # shellcheck disable=SC2154
                 (
                     test_setup && test_run
                     ret=$?
@@ -90,7 +92,7 @@ while (($# > 0)); do
                     rm -fr -- "$TESTDIR"
                     rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
                     exit $ret
-                ) < /dev/null 2>&1 | $basedir/logtee test${TEST_RUN_ID:+-$TEST_RUN_ID}.log
+                ) < /dev/null 2>&1 | "$basedir/logtee" "test${TEST_RUN_ID:+-$TEST_RUN_ID}.log"
             else
                 (
                     test_setup && test_run
@@ -105,12 +107,12 @@ while (($# > 0)); do
             set +o pipefail
             if [ $ret -eq 0 ]; then
                 rm -- test${TEST_RUN_ID:+-$TEST_RUN_ID}.log
-                echo -e "TEST: $TEST_DESCRIPTION " $COLOR_SUCCESS "[OK]" $COLOR_NORMAL
+                echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_SUCCESS" "[OK]" "$COLOR_NORMAL"
             else
-                echo -e "TEST: $TEST_DESCRIPTION " $COLOR_FAILURE "[FAILED]" $COLOR_NORMAL
+                echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_FAILURE" "[FAILED]" "$COLOR_NORMAL"
                 if [ "$V" == "2" ]; then
-                    tail -c 1048576 $(pwd)/server${TEST_RUN_ID:+-$TEST_RUN_ID}.log $(pwd)/test${TEST_RUN_ID:+-$TEST_RUN_ID}.log
-                    echo -e "TEST: $TEST_DESCRIPTION " $COLOR_FAILURE "[FAILED]" $COLOR_NORMAL
+                    tail -c 1048576 "$(pwd)/server${TEST_RUN_ID:+-$TEST_RUN_ID}.log" "$(pwd)/test${TEST_RUN_ID:+-$TEST_RUN_ID}.log"
+                    echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_FAILURE" "[FAILED]" "$COLOR_NORMAL"
                 else
                     echo "see $(pwd)/test${TEST_RUN_ID:+-$TEST_RUN_ID}.log"
                 fi