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
|
2019-06-15 16:28:44 +02:00
|
|
|
all_skipped=0
|
2021-05-17 10:11:09 +02:00
|
|
|
rep_failed=0
|
2010-06-10 08:48:00 +02:00
|
|
|
|
|
|
|
for file
|
|
|
|
do
|
2021-05-17 10:11:09 +02:00
|
|
|
if [ ! -f "$file" ]; then
|
|
|
|
echo "'$file' does not exist!"
|
|
|
|
rep_failed=$((rep_failed + 1))
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
has_total=0
|
2010-06-10 08:48:00 +02:00
|
|
|
while read type value
|
|
|
|
do
|
|
|
|
case $type in
|
|
|
|
fixed)
|
2019-06-10 20:39:23 +02:00
|
|
|
fixed=$((fixed + value)) ;;
|
2010-06-10 08:48:00 +02:00
|
|
|
success)
|
2019-06-10 20:39:23 +02:00
|
|
|
success=$((success + value)) ;;
|
2010-06-10 08:48:00 +02:00
|
|
|
failed)
|
2019-06-10 20:39:23 +02:00
|
|
|
failed=$((failed + value)) ;;
|
2010-06-10 08:48:00 +02:00
|
|
|
broken)
|
2019-06-10 20:39:23 +02:00
|
|
|
broken=$((broken + value)) ;;
|
2010-06-10 08:48:00 +02:00
|
|
|
total)
|
2019-06-15 16:28:44 +02:00
|
|
|
total=$((total + value))
|
2021-05-17 10:11:09 +02:00
|
|
|
has_total=1
|
2019-06-15 16:28:44 +02:00
|
|
|
if [ "$value" -eq 0 ]; then
|
|
|
|
all_skipped=$((all_skipped + 1))
|
|
|
|
fi
|
2010-06-10 08:48:00 +02:00
|
|
|
esac
|
|
|
|
done <"$file"
|
2021-05-17 10:11:09 +02:00
|
|
|
if [ "$has_total" -eq 0 ]; then
|
|
|
|
echo "'$file' lacks 'total ...'; results may be inconsistent."
|
|
|
|
failed=$((failed + 1))
|
|
|
|
fi
|
2010-06-10 08:48:00 +02:00
|
|
|
done
|
|
|
|
|
2019-06-10 20:39:23 +02:00
|
|
|
pluralize_s () { [ "$1" -eq 1 ] && s='' || s='s'; }
|
2010-09-17 22:53:47 +02:00
|
|
|
|
|
|
|
echo "Notmuch test suite complete."
|
2019-06-10 20:39:23 +02:00
|
|
|
|
2021-05-17 10:11:09 +02:00
|
|
|
if [ "$fixed" -eq 0 ] && [ "$failed" -eq 0 ] && [ "$rep_failed" -eq 0 ]; then
|
2019-06-10 20:39:23 +02:00
|
|
|
pluralize_s "$total"
|
|
|
|
printf "All $total test$s "
|
|
|
|
if [ "$broken" -eq 0 ]; then
|
|
|
|
echo "passed."
|
|
|
|
else
|
|
|
|
pluralize_s "$broken"
|
|
|
|
echo "behaved as expected ($broken expected failure$s)."
|
|
|
|
fi
|
2010-09-17 22:53:47 +02:00
|
|
|
else
|
2019-06-10 20:39:23 +02:00
|
|
|
echo "$success/$total tests passed."
|
|
|
|
if [ "$broken" -ne 0 ]; then
|
|
|
|
pluralize_s "$broken"
|
|
|
|
echo "$broken broken test$s failed as expected."
|
|
|
|
fi
|
|
|
|
if [ "$fixed" -ne 0 ]; then
|
|
|
|
pluralize_s "$fixed"
|
|
|
|
echo "$fixed broken test$s now fixed."
|
|
|
|
fi
|
|
|
|
if [ "$failed" -ne 0 ]; then
|
|
|
|
pluralize_s "$failed"
|
|
|
|
echo "$failed test$s failed."
|
|
|
|
fi
|
2010-09-17 22:53:47 +02:00
|
|
|
fi
|
|
|
|
|
2019-06-10 20:39:23 +02:00
|
|
|
skipped=$((total - fixed - success - failed - broken))
|
|
|
|
if [ "$skipped" -ne 0 ]; then
|
|
|
|
pluralize_s "$skipped"
|
|
|
|
echo "$skipped test$s skipped."
|
2010-09-17 22:53:47 +02:00
|
|
|
fi
|
2019-06-15 16:28:44 +02:00
|
|
|
if [ "$all_skipped" -ne 0 ]; then
|
|
|
|
pluralize_s "$all_skipped"
|
|
|
|
echo "All tests in $all_skipped file$s skipped."
|
|
|
|
fi
|
2013-09-08 17:53:30 +02:00
|
|
|
|
2021-05-17 10:11:09 +02:00
|
|
|
if [ "$rep_failed" -ne 0 ]; then
|
|
|
|
pluralize_s "$rep_failed"
|
|
|
|
echo "$rep_failed test$s failed to report results."
|
|
|
|
fi
|
|
|
|
|
2015-09-24 13:13:30 +02:00
|
|
|
# Note that we currently do not consider skipped tests as failing the
|
|
|
|
# build.
|
|
|
|
|
2021-05-17 10:11:09 +02:00
|
|
|
if [ "$success" -gt 0 ] && [ "$fixed" -eq 0 ] &&
|
|
|
|
[ "$failed" -eq 0 ] && [ "$rep_failed" -eq 0 ]
|
2013-09-08 17:53:30 +02:00
|
|
|
then
|
2019-06-10 20:39:23 +02:00
|
|
|
exit 0
|
2013-09-08 17:53:30 +02:00
|
|
|
else
|
2019-06-10 20:39:23 +02:00
|
|
|
exit 1
|
2013-09-08 17:53:30 +02:00
|
|
|
fi
|