From 1058d031e2046eb80331b0950eaff75c2bf608dc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 9 May 2012 07:30:07 +0200 Subject: [PATCH] Make hb-diff-filter-failtures retain all test info for failed tests --- test/shaping/hb_test_tools.py | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/test/shaping/hb_test_tools.py b/test/shaping/hb_test_tools.py index 03a7710..17181ac 100644 --- a/test/shaping/hb_test_tools.py +++ b/test/shaping/hb_test_tools.py @@ -149,16 +149,35 @@ class ZipDiffer: class DiffFilters: @staticmethod - def filter_failures (f, symbols=diff_symbols): - for l in f: - if l[0] in symbols: - # TODO retain all lines of the failure - yield l + def filter_failures (f): + for lines in DiffHelpers.separate_test_cases (f): + if any (l[0] != ' ' for l in lines): + for l in lines: yield l +class DiffHelpers: -class ShapeFilters: + @staticmethod + def separate_test_cases (f): + '''Reads lines from f, and if the lines have identifiers, ie. + have a colon character, groups them by identifier, + yielding lists of all lines with the same identifier.''' - pass + acc = [] + iden = None + for l in f: + if ':' not in l: + if acc: yield acc + acc = [] + iden = None + yield [l] + continue + l_iden = l[1:l.index (':')] + if acc and iden != l_iden: + yield acc + acc = [] + iden = l_iden + acc.append (l) + if acc: yield acc class FilterHelpers: -- 2.7.4