aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/external/c-testsuite/scripts/tapsummary
blob: e73520d64b8274fe003c41dcf886f138fa95ccd1 (plain) (blame)
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
#! /usr/bin/env python3

import sys
import tempfile

tfailed=False

buffered=tempfile.TemporaryFile()
def o(l):
    global buffered
    buffered.write(l.encode('utf-8'))

print("Test summary:")
print("")

ntests=None
passed=0
failed=0
skipped=0

for l in sys.stdin:
    if l.startswith("not ok"):
        o(l)
        failed += 1
        tfailed=True
    elif l.startswith("ok"):
        if "# SKIP" in l:
            skipped += 1
        else:
            passed += 1
        tfailed=False
    elif l.startswith('1..'):
        ntests = int(l[3:])
    elif l.startswith('#'):
        if tfailed:
            o('  '+l[1:])

if ntests is None:
    raise Exception("expected a 1..n line")

if ntests != passed+failed+skipped:
    raise Exception("%s tests did not report results"%(ntests-(passed+failed),))

print("pass %d" % passed)
print("fail %d" % failed)
print("skip %d" % skipped)
totalln = "total %d" % ntests
print("-"*len(totalln))
print(totalln)

print("")
buffered.seek(0)
try:
    while True:
        buf = buffered.read(4096)
        if len(buf) == 0:
            break
        sys.stdout.write(buf.decode('utf-8'))
except BrokenPipeError:
    pass
sys.stdout.flush()
buffered.close()