Add_test, Genlog: New File ID
[gpstools.git] / tests / Genlog
blob553f4caa5ebca03a54177b4fde63fb95beddc7fd
1 #!/bin/bash
3 #=======================================================================
4 # Genlog
5 # File ID: f12ac9d0-28f3-11e5-9579-fefdb24f8e10
7 # Run all tests, update files in log/ and display the results.
9 # License: GNU General Public License version 2 or later.
10 #=======================================================================
12 [ -z "$1" ] && { echo "Syntax: $0 testname [testname [...]]" >&2; exit 1; }
14 mkdir -p log
15 maxlen=0
16 retval=0
17 tot_ok=0
18 tot_not_ok=0
20 for gf in "$@"; do
21 currlen=`echo -n $gf | perl -pe 's/\.t$//' | wc -c`
22 [ $currlen -gt $maxlen ] && maxlen=$currlen
23 done
25 for gf in "$@"; do
26 testname=$gf
27 testname=`echo -n $testname | perl -pe 's/\.t$//'`
28 printf "%${maxlen}s.t: " $testname
29 ./$testname.t 2>&1 | remove_perltestnumbers >log/$testname.log
30 not_ok_count=$(grep "^not ok -" log/$testname.log | wc -l | tr -d ' ')
31 if [ $not_ok_count -gt 0 ]; then
32 not_ok_str=", $not_ok_count not ok"
33 retval=1
34 else
35 unset not_ok_str
37 ok_count=$(grep "^ok -" log/$testname.log | wc -l)
38 printf "%3u ok%s\\n" $ok_count "$not_ok_str"
39 tot_ok=$(($tot_ok + $ok_count))
40 tot_not_ok=$(($tot_not_ok + $not_ok_count))
41 grep -q "^not ok -" log/$testname.log && {
42 echo
43 grep "^not ok -" log/$testname.log
44 echo
46 done
47 echo
48 printf " %${maxlen}s: %u ok, %u not ok\n" "total" $tot_ok $tot_not_ok
50 exit $retval