2010-12-01 21:27:52 +01:00
|
|
|
#!/usr/bin/env bash
|
2010-06-10 08:48:00 +02:00
|
|
|
|
2013-09-08 17:53:30 +02:00
|
|
|
set -eu
|
|
|
|
|
2010-06-10 08:48:00 +02:00
|
|
|
fixed=0
|
|
|
|
success=0
|
|
|
|
failed=0
|
|
|
|
broken=0
|
|
|
|
total=0
|
|
|
|
|
|
|
|
for file
|
|
|
|
do
|
|
|
|
while read type value
|
|
|
|
do
|
|
|
|
case $type in
|
|
|
|
'')
|
|
|
|
continue ;;
|
|
|
|
fixed)
|
|
|
|
fixed=$(($fixed + $value)) ;;
|
|
|
|
success)
|
|
|
|
success=$(($success + $value)) ;;
|
|
|
|
failed)
|
|
|
|
failed=$(($failed + $value)) ;;
|
|
|
|
broken)
|
|
|
|
broken=$(($broken + $value)) ;;
|
|
|
|
total)
|
|
|
|
total=$(($total + $value)) ;;
|
|
|
|
esac
|
|
|
|
done <"$file"
|
|
|
|
done
|
|
|
|
|
2010-09-17 22:53:47 +02:00
|
|
|
pluralize () {
|
|
|
|
case $2 in
|
|
|
|
1)
|
|
|
|
case $1 in
|
|
|
|
test)
|
|
|
|
echo test ;;
|
|
|
|
failure)
|
|
|
|
echo failure ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
case $1 in
|
|
|
|
test)
|
|
|
|
echo tests ;;
|
|
|
|
failure)
|
|
|
|
echo failures ;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "Notmuch test suite complete."
|
2010-09-20 23:39:40 +02:00
|
|
|
if [ "$fixed" = "0" ] && [ "$failed" = "0" ]; then
|
2010-09-17 22:53:47 +02:00
|
|
|
tests=$(pluralize "test" $total)
|
|
|
|
printf "All $total $tests "
|
|
|
|
if [ "$broken" = "0" ]; then
|
|
|
|
echo "passed."
|
|
|
|
else
|
|
|
|
failures=$(pluralize "failure" $broken)
|
|
|
|
echo "behaved as expected ($broken expected $failures)."
|
|
|
|
fi;
|
|
|
|
else
|
|
|
|
echo "$success/$total tests passed."
|
|
|
|
if [ "$broken" != "0" ]; then
|
|
|
|
tests=$(pluralize "test" $broken)
|
|
|
|
echo "$broken broken $tests failed as expected."
|
|
|
|
fi
|
|
|
|
if [ "$fixed" != "0" ]; then
|
|
|
|
tests=$(pluralize "test" $fixed)
|
|
|
|
echo "$fixed broken $tests now fixed."
|
|
|
|
fi
|
|
|
|
if [ "$failed" != "0" ]; then
|
|
|
|
tests=$(pluralize "test" $failed)
|
|
|
|
echo "$failed $tests failed."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
skipped=$(($total - $fixed - $success - $failed - $broken))
|
|
|
|
if [ "$skipped" != "0" ]; then
|
|
|
|
tests=$(pluralize "test" $skipped)
|
|
|
|
echo "$skipped $tests skipped."
|
|
|
|
fi
|
2013-09-08 17:53:30 +02:00
|
|
|
|
|
|
|
if [ $success -gt 0 -a $fixed -eq 0 -a $failed -eq 0 -a $skipped -eq 0 ]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|