PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/aggregate-results.sh

https://code.google.com/
Shell | 81 lines | 75 code | 5 blank | 1 comment | 13 complexity | f60d93134ce10b67d8a96a502980b29f MD5 | raw file
 1#!/bin/sh
 2
 3fixed=0
 4success=0
 5failed=0
 6broken=0
 7total=0
 8
 9for file
10do
11	while read type value
12	do
13		case $type in
14		'')
15			continue ;;
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"
28done
29
30pluralize () {
31    case $2 in
32	1)
33	    case $1 in
34		test)
35		    echo test ;;
36		failure)
37		    echo failure ;;
38	    esac
39	    ;;
40	*)
41	    case $1 in
42		test)
43		    echo tests ;;
44		failure)
45		    echo failures ;;
46	    esac
47	    ;;
48    esac
49}
50
51echo "pdsh test suite complete."
52if [ "$fixed" = "0" ] && [ "$failed" = "0" ]; then
53    tests=$(pluralize "test" $total)
54    printf "All $total $tests "
55    if [ "$broken" = "0" ]; then
56	echo "passed."
57    else
58	failures=$(pluralize "failure" $broken)
59	echo "behaved as expected ($broken expected $failures)."
60    fi;
61else
62    echo "$success/$total tests passed."
63    if [ "$broken" != "0" ]; then
64	tests=$(pluralize "test" $broken)
65	echo "$broken broken $tests failed as expected."
66    fi
67    if [ "$fixed" != "0" ]; then
68	tests=$(pluralize "test" $fixed)
69	echo "$fixed broken $tests now fixed."
70    fi
71    if [ "$failed" != "0" ]; then
72	tests=$(pluralize "test" $failed)
73	echo "$failed $tests failed."
74    fi
75fi
76
77skipped=$(($total - $fixed - $success - $failed - $broken))
78if [ "$skipped" != "0" ]; then
79    tests=$(pluralize "test" $skipped)
80    echo "$skipped $tests skipped."
81fi