From baa4acd4027eb33a0bc92bda189bdf967505be8b Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 30 Mar 2021 10:40:13 +0200 Subject: [PATCH] fix(test/test-functions): shellcheck for test/test-functions --- test/test-functions | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/test-functions b/test/test-functions index 53da5cc5b..73b478009 100644 --- a/test/test-functions +++ b/test/test-functions @@ -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 -- 2.47.3