]> git.notmuchmail.org Git - notmuch/blob - test/aggregate-results.sh
Merge branch 'release'
[notmuch] / test / aggregate-results.sh
1 #!/usr/bin/env bash
2
3 set -eu
4
5 fixed=0
6 success=0
7 failed=0
8 broken=0
9 total=0
10
11 for file
12 do
13         while read type value
14         do
15                 case $type in
16                 fixed)
17                         fixed=$((fixed + value)) ;;
18                 success)
19                         success=$((success + value)) ;;
20                 failed)
21                         failed=$((failed + value)) ;;
22                 broken)
23                         broken=$((broken + value)) ;;
24                 total)
25                         total=$((total + value)) ;;
26                 esac
27         done <"$file"
28 done
29
30 pluralize_s () { [ "$1" -eq 1 ] && s='' || s='s'; }
31
32 echo "Notmuch test suite complete."
33
34 if [ "$fixed" -eq 0 ] && [ "$failed" -eq 0 ]; then
35         pluralize_s "$total"
36         printf "All $total test$s "
37         if [ "$broken" -eq 0 ]; then
38                 echo "passed."
39         else
40                 pluralize_s "$broken"
41                 echo "behaved as expected ($broken expected failure$s)."
42         fi
43 else
44         echo "$success/$total tests passed."
45         if [ "$broken" -ne 0 ]; then
46                 pluralize_s "$broken"
47                 echo "$broken broken test$s failed as expected."
48         fi
49         if [ "$fixed" -ne 0 ]; then
50                 pluralize_s "$fixed"
51                 echo "$fixed broken test$s now fixed."
52         fi
53         if [ "$failed" -ne 0 ]; then
54                 pluralize_s "$failed"
55                 echo "$failed test$s failed."
56         fi
57 fi
58
59 skipped=$((total - fixed - success - failed - broken))
60 if [ "$skipped" -ne 0 ]; then
61         pluralize_s "$skipped"
62         echo "$skipped test$s skipped."
63 fi
64
65 # Note that we currently do not consider skipped tests as failing the
66 # build.
67
68 if [ "$success" -gt 0 ] && [ "$fixed" -eq 0 ] && [ "$failed" -eq 0 ]
69 then
70         exit 0
71 else
72         exit 1
73 fi