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