aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/external/c-testsuite/scripts/tapsummary
diff options
context:
space:
mode:
Diffstat (limited to 'test/external/c-testsuite/scripts/tapsummary')
-rwxr-xr-xtest/external/c-testsuite/scripts/tapsummary62
1 files changed, 62 insertions, 0 deletions
diff --git a/test/external/c-testsuite/scripts/tapsummary b/test/external/c-testsuite/scripts/tapsummary
new file mode 100755
index 0000000..e73520d
--- /dev/null
+++ b/test/external/c-testsuite/scripts/tapsummary
@@ -0,0 +1,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()