Browse Source

fix(test/test-functions): shellcheck for test/test-functions

master
Harald Hoyer 4 years ago committed by Harald Hoyer
parent
commit
baa4acd402
  1. 18
      test/test-functions

18
test/test-functions

@ -2,6 +2,7 @@ @@ -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 @@ -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 @@ -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 @@ -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 @@ -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

Loading…
Cancel
Save