test: Count succeeded/failed tests

Bu işleme şunda yer alıyor:
Albert S. 2021-06-06 09:02:30 +02:00
ebeveyn b8d6c78780
işleme 5138d88b12

33
test.sh
Dosyayı Görüntüle

@ -3,6 +3,9 @@ GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
COUNT_SUCCEEDED=0
COUNT_FAILED=0
function print_fail()
{
echo -e "${RED}$@${NC}" 1>&2
@ -13,6 +16,19 @@ function print_success()
echo -e "${GREEN}$@${NC}"
}
function runtest_fail()
{
print_fail "failed"
COUNT_FAILED=$(($COUNT_FAILED+1))
}
function runtest_success()
{
print_success "ok"
COUNT_SUCCEEDED=$((COUNT_SUCCEEDED+1))
}
function runtest()
{
must_exit_zero=$2
@ -22,15 +38,15 @@ function runtest()
ret=$?
if [ $must_exit_zero -eq 1 ] ; then
if [ $ret -eq 0 ] ; then
print_success "ok"
runtest_success
else
print_fail "fail"
runtest_fail
fi
else
if [ $ret -eq 0 ] ; then
print_fail "fail"
runtest_fail
else
print_success "ok"
runtest_success
fi
fi
}
@ -40,3 +56,12 @@ for test in $( ./test --dumptests ) ; do
must_exit_zero=$( echo "$test" | cut -d":" -f2 )
runtest "$testname" $must_exit_zero
done
echo
echo "Tests finished:"
echo "Succeeded: $COUNT_SUCCEEDED"
echo "Failed: $COUNT_FAILED"
if [ $COUNT_FAILED -gt 0 ] ; then
exit 1
fi
exit 0