#! /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()