-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGenlog
executable file
·119 lines (99 loc) · 2.82 KB
/
Genlog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh
#=======================================================================
# Genlog
# File ID: STDuuidDTS
#
# Run all tests, update files in log/ of that directory and display the
# results.
#
# Author: Øyvind A. Holm <[email protected]>
# License: GNU General Public License version 2 or later.
#=======================================================================
progname=Genlog
VERSION=0.6.0
if test "$1" = "--version"; then
echo $progname $VERSION
exit 0
fi
if test -z "$1" -o "$1" = "-h" -o "$1" = "--help"; then
cat <<END
Run all tests, update files in log/ of that directory and display the
results.
The exit value is a bitwise OR:
Bit 0 set: One or more tests failed
Bit 1 set: Bail out detected (one or more test scripts aborted)
That is:
0: Everything ok
1: One or more tests failed
2: One or more scripts aborted
3: Tests failed and scripts aborted
Lines starting with "# NOTICE:" are displayed during the run. They don't
affect the exit value, so they can for example be used to inform the
user that tests have been skipped.
Usage: $progname testname [options] [testname [...]]
Options:
-h, --help
Show this help.
--version
Print version information.
END
exit 0
fi
[ -z "$1" ] && {
echo "Syntax: $0 testname [options] [testname [...]]" >&2
exit 1
}
mkdir -p log
maxlen=0
retval=0
tot_bailout=0
tot_ok=0
tot_not_ok=0
opt_str=
while printf "%s" "$1" | grep -q ^-; do
opt_str="$opt_str $1"
shift
done
for gf in "$@"; do
currlen=`echo -n $gf | wc -c`
[ $currlen -gt $maxlen ] && maxlen=$currlen
done
for gf in "$@"; do
testname=$gf
printf "%${maxlen}s: " $testname
./$testname $opt_str 2>&1 |
perl -pe 's/^((not )?ok)( \d+ )- /$1 - /;' >log/$testname.log
not_ok_count=$(grep -a "^not ok" log/$testname.log | wc -l | tr -d ' ')
if [ $not_ok_count -gt 0 ]; then
not_ok_str=", $not_ok_count not ok"
retval=$(($retval | 1))
else
unset not_ok_str
fi
ok_count=$(grep -a "^ok" log/$testname.log | wc -l)
printf "%3u ok%s\\n" $ok_count "$not_ok_str"
tot_ok=$(($tot_ok + $ok_count))
tot_not_ok=$(($tot_not_ok + $not_ok_count))
grep -a -q "^not ok" log/$testname.log && {
echo
grep -a "^not ok" log/$testname.log
echo
}
grep -a "^Bail out" log/$testname.log && retval=$(($retval | 2))
tot_bailout=$((
$tot_bailout + $(grep -a "^Bail out" log/$testname.log | wc -l)
))
grep -a "^# NOTICE:" log/$testname.log
done
echo
unset tot_not_ok_str
if test $tot_not_ok -gt 0; then
tot_not_ok_str=", $tot_not_ok not ok ($tot_not_ok/$((
$tot_ok + $tot_not_ok
)) FAIL)"
fi
printf "%${maxlen}s: %u ok%s\n" "total" "$tot_ok" "$tot_not_ok_str"
if test $tot_bailout -gt 0; then
printf "%${maxlen}s: %u\n" "bailout" "$tot_bailout"
fi
exit $retval