File: summarize.sh

package info (click to toggle)
yash 2.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,152 kB
  • sloc: ansic: 34,578; makefile: 851; sh: 808; sed: 16
file content (64 lines) | stat: -rw-r--r-- 1,851 bytes parent folder | download
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
# summarize.sh: extracts errors from test results
# (C) 2015-2025 magicant
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

set -Ceu

export LC_ALL=C

uname -a
date
printf '=============\n\n'

ok=0 error=0 skipped=0

for result_file do
    # The "grep" command is generally faster than repeated "read" built-in.
    if [ "$(grep -cE '^%%% (ERROR\[|SKIPPED:)' "$result_file")" -eq 0 ]; then
        ok="$((ok + $(grep -c '^%%% OK\[' "$result_file" || true)))"
        continue
    fi

    log=''
    while IFS= read -r line; do
        log="$log
$line"
        case $line in
            ('%%% START:'*)
                log="$line"
                ;;
            ('%%% OK['*)
                ok="$((ok + 1))"
                ;;
            ('%%% ERROR['*)
                printf '%s\n\n' "$log"
                error="$((error + 1))"
                ;;
            ('%%% SKIPPED:'*)
                printf '%s\n\n' "$line"
                skipped="$((skipped + 1))"
                ;;
        esac
    done <"$result_file"
done

printf '==============\n'
printf 'TOTAL:   %5d\n' "$((ok + error + skipped))"
printf 'OK:      %5d\n' "$ok"
printf 'ERROR:   %5d\n' "$error"
printf 'SKIPPED: %5d\n' "$skipped"
printf '==============\n'

# vim: set ts=8 sts=4 sw=4 et: