Add hb-diff-stat
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 9 May 2012 05:45:17 +0000 (07:45 +0200)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 9 May 2012 05:45:17 +0000 (07:45 +0200)
test/shaping/Makefile.am
test/shaping/hb-diff-stat [new file with mode: 0755]
test/shaping/hb_test_tools.py

index f216c5d..81c9991 100644 (file)
@@ -13,6 +13,7 @@ EXTRA_DIST += \
        hb-diff \
        hb-diff-colorize \
        hb-diff-filter-failures \
+       hb-diff-stat \
        hb-manifest-read \
        hb-manifest-update \
        hb-unicode-decode \
diff --git a/test/shaping/hb-diff-stat b/test/shaping/hb-diff-stat
new file mode 100755 (executable)
index 0000000..81626e1
--- /dev/null
@@ -0,0 +1,5 @@
+#!/usr/bin/python
+
+from hb_test_tools import *
+
+UtilMains.process_multiple_files (DiffSinks.print_stat)
index 17181ac..70a9ce1 100644 (file)
@@ -151,9 +151,23 @@ class DiffFilters:
        @staticmethod
        def filter_failures (f):
                for lines in DiffHelpers.separate_test_cases (f):
-                       if any (l[0] != ' ' for l in lines):
+                       if not DiffHelpers.test_passed (lines):
                                for l in lines: yield l
 
+class DiffSinks:
+
+       @staticmethod
+       def print_stat (f):
+               passed = 0
+               failed = 0
+               for lines in DiffHelpers.separate_test_cases (f):
+                       if DiffHelpers.test_passed (lines):
+                               passed += 1
+                       else:
+                               failed += 1
+               total = passed + failed
+               print "%d out of %d tests passed.  %d failed (%g%%)" % (passed, total, failed, 100. * failed / total)
+
 class DiffHelpers:
 
        @staticmethod
@@ -175,10 +189,14 @@ class DiffHelpers:
                        if acc and iden != l_iden:
                                yield acc
                                acc = []
-                               iden = l_iden
+                       iden = l_iden
                        acc.append (l)
                if acc: yield acc
 
+       @staticmethod
+       def test_passed (lines):
+               return all (l[0] == ' ' for l in lines)
+
 
 class FilterHelpers: