test/test-functions: fixed V=1 logic

master
Harald Hoyer 2018-08-17 15:38:03 +02:00
parent f19063ac71
commit 09132c732a
1 changed files with 50 additions and 50 deletions

View File

@ -38,79 +38,79 @@ while (($# > 0)); do
case $1 in
--run)
check_root
echo "TEST RUN: $TEST_DESCRIPTION"
test_check && test_run
exit $?;;
echo "TEST RUN: $TEST_DESCRIPTION"
test_check && test_run
exit $?;;
--setup)
check_root
echo "TEST SETUP: $TEST_DESCRIPTION"
test_check && test_setup
exit $?;;
echo "TEST SETUP: $TEST_DESCRIPTION"
test_check && test_setup
exit $?;;
--clean)
echo "TEST CLEANUP: $TEST_DESCRIPTION"
test_cleanup
rm -fr -- "$TESTDIR"
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
exit $?;;
echo "TEST CLEANUP: $TEST_DESCRIPTION"
test_cleanup
rm -fr -- "$TESTDIR"
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
exit $?;;
--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
exit 0;
echo -e "TEST: $TEST_DESCRIPTION " $COLOR_WARNING "[SKIPPED]" $COLOR_NORMAL
exit 0;
else
echo "TEST: $TEST_DESCRIPTION [STARTED]";
echo "TEST: $TEST_DESCRIPTION [STARTED]";
fi
if [[ "$V" == "1" ]]; then
(
test_setup && test_run
ret=$?
test_cleanup
rm -fr -- "$TESTDIR"
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
exit $ret
) </dev/null >test${TEST_RUN_ID:+-$TEST_RUN_ID}.log 2>&1
set -o pipefail
(
test_setup && test_run
ret=$?
test_cleanup
if ((ret!=0)) && [[ -f "$TESTDIR"/server.log ]]; then
mv [[ -f "$TESTDIR"/server.log ]] ./server${TEST_RUN_ID:+-$TEST_RUN_ID}.log
fi
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
elif [[ "$V" == "2" ]]; then
set -o pipefail
(
test_setup && test_run
ret=$?
test_cleanup
test_setup && test_run
ret=$?
test_cleanup
if ((ret!=0)) && [[ -f "$TESTDIR"/server.log ]]; then
mv [[ -f "$TESTDIR"/server.log ]] ./server${TEST_RUN_ID:+-$TEST_RUN_ID}.log
fi
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
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
else
set -o pipefail
(
test_setup && test_run
ret=$?
test_cleanup
if ((ret!=0)) && [[ -f "$TESTDIR"/server.log ]]; then
mv [[ -f "$TESTDIR"/server.log ]] ./server${TEST_RUN_ID:+-$TEST_RUN_ID}.log
fi
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
test_setup && test_run
ret=$?
test_cleanup
rm -fr -- "$TESTDIR"
rm -f -- .testdir${TEST_RUN_ID:+-$TEST_RUN_ID}
exit $ret
) </dev/null >test${TEST_RUN_ID:+-$TEST_RUN_ID}.log 2>&1
fi
ret=$?
ret=$?
set +o pipefail
if [ $ret -eq 0 ]; then
if [ $ret -eq 0 ]; then
rm -- test${TEST_RUN_ID:+-$TEST_RUN_ID}.log
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_SUCCESS "[OK]" $COLOR_NORMAL
else
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"
echo "see $(pwd)/test${TEST_RUN_ID:+-$TEST_RUN_ID}.log"
fi
fi
exit $ret;;
fi
exit $ret;;
*) break ;;
esac
shift