From c438a14b62433db488b5c90854a4a3934adf3305 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 9 May 2012 07:45:17 +0200 Subject: [PATCH] Add hb-diff-stat --- test/shaping/Makefile.am | 1 + test/shaping/hb-diff-stat | 5 +++++ test/shaping/hb_test_tools.py | 22 ++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 test/shaping/hb-diff-stat diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am index f216c5d..81c9991 100644 --- a/test/shaping/Makefile.am +++ b/test/shaping/Makefile.am @@ -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 index 0000000..81626e1 --- /dev/null +++ b/test/shaping/hb-diff-stat @@ -0,0 +1,5 @@ +#!/usr/bin/python + +from hb_test_tools import * + +UtilMains.process_multiple_files (DiffSinks.print_stat) diff --git a/test/shaping/hb_test_tools.py b/test/shaping/hb_test_tools.py index 17181ac..70a9ce1 100644 --- a/test/shaping/hb_test_tools.py +++ b/test/shaping/hb_test_tools.py @@ -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: -- 2.7.4