Add hb-diff-stat
This commit is contained in:
parent
1058d031e2
commit
c438a14b62
|
@ -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 \
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from hb_test_tools import *
|
||||
|
||||
UtilMains.process_multiple_files (DiffSinks.print_stat)
|
|
@ -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
|
||||
|
@ -179,6 +193,10 @@ class DiffHelpers:
|
|||
acc.append (l)
|
||||
if acc: yield acc
|
||||
|
||||
@staticmethod
|
||||
def test_passed (lines):
|
||||
return all (l[0] == ' ' for l in lines)
|
||||
|
||||
|
||||
class FilterHelpers:
|
||||
|
||||
|
|
Loading…
Reference in New Issue