test: Count succeeded/failed tests
This commit is contained in:
parent
b8d6c78780
commit
5138d88b12
33
test.sh
33
test.sh
@ -3,6 +3,9 @@ GREEN='\033[0;32m'
|
|||||||
RED='\033[0;31m'
|
RED='\033[0;31m'
|
||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
|
COUNT_SUCCEEDED=0
|
||||||
|
COUNT_FAILED=0
|
||||||
|
|
||||||
function print_fail()
|
function print_fail()
|
||||||
{
|
{
|
||||||
echo -e "${RED}$@${NC}" 1>&2
|
echo -e "${RED}$@${NC}" 1>&2
|
||||||
@ -13,6 +16,19 @@ function print_success()
|
|||||||
echo -e "${GREEN}$@${NC}"
|
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()
|
function runtest()
|
||||||
{
|
{
|
||||||
must_exit_zero=$2
|
must_exit_zero=$2
|
||||||
@ -22,15 +38,15 @@ function runtest()
|
|||||||
ret=$?
|
ret=$?
|
||||||
if [ $must_exit_zero -eq 1 ] ; then
|
if [ $must_exit_zero -eq 1 ] ; then
|
||||||
if [ $ret -eq 0 ] ; then
|
if [ $ret -eq 0 ] ; then
|
||||||
print_success "ok"
|
runtest_success
|
||||||
else
|
else
|
||||||
print_fail "fail"
|
runtest_fail
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ $ret -eq 0 ] ; then
|
if [ $ret -eq 0 ] ; then
|
||||||
print_fail "fail"
|
runtest_fail
|
||||||
else
|
else
|
||||||
print_success "ok"
|
runtest_success
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -40,3 +56,12 @@ for test in $( ./test --dumptests ) ; do
|
|||||||
must_exit_zero=$( echo "$test" | cut -d":" -f2 )
|
must_exit_zero=$( echo "$test" | cut -d":" -f2 )
|
||||||
runtest "$testname" $must_exit_zero
|
runtest "$testname" $must_exit_zero
|
||||||
done
|
done
|
||||||
|
echo
|
||||||
|
echo "Tests finished:"
|
||||||
|
echo "Succeeded: $COUNT_SUCCEEDED"
|
||||||
|
echo "Failed: $COUNT_FAILED"
|
||||||
|
|
||||||
|
if [ $COUNT_FAILED -gt 0 ] ; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user