[Piglit] [PATCH 3/3] framework/sumamry/common.py: Fix subtest handling in non-all groups

Dylan Baker baker.dylan.c at gmail.com
Tue Oct 20 15:31:10 PDT 2015


Thanks for testing Marek. Sorry that I broke so many corners of the
summary code.

On Tue, Oct 20, 2015 at 12:32:06PM +0200, Marek Olšák wrote:
> Thanks. It works like a charm.
> 
> Tested-by: Marek Olšák <marek.olsak at amd.com>
> 
> Marek
> 
> On Tue, Oct 20, 2015 at 12:34 AM,  <baker.dylan.c at gmail.com> wrote:
> > From: Dylan Baker <baker.dylan.c at gmail.com>
> >
> > The gist of the problem is that we handle lookup for subtests in the all
> > group correctly, but when we went to compare between multiple results we
> > don't.
> >
> > This patch makes use of the get_result from the previous patch to
> > simplify test name lookups, and fix the non-all case.
> >
> > Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> > ---
> >  framework/summary/common.py              | 33 +++++++++++++++++---------------
> >  framework/tests/summary_console_tests.py |  2 +-
> >  2 files changed, 19 insertions(+), 16 deletions(-)
> >
> > diff --git a/framework/summary/common.py b/framework/summary/common.py
> > index b67a983..95af02a 100644
> > --- a/framework/summary/common.py
> > +++ b/framework/summary/common.py
> > @@ -55,19 +55,9 @@ class Results(object):  # pylint: disable=too-few-public-methods
> >          results = []
> >          for res in self.results:
> >              try:
> > -                results.append(res.tests[name].result)
> > +                results.append(res.get_result(name))
> >              except KeyError:
> >                  results.append(so.NOTRUN)
> > -        if all(x == so.NOTRUN for x in results):
> > -            # this is likely a subtest, see if that's the case
> > -            name, test = grouptools.splitname(name)
> > -
> > -            results = []
> > -            for res in self.results:
> > -                try:
> > -                    results.append(res.tests[name].subtests[test])
> > -                except KeyError:
> > -                    results.append(so.NOTRUN)
> >          return results
> >
> >
> > @@ -138,8 +128,9 @@ class Names(object):
> >      @lazy_property
> >      def enabled(self):
> >          def handler(names, name, prev, cur):
> > -            if name not in prev.tests and name in cur.tests:
> > +            if _result_in(name, cur) and not _result_in(name, prev):
> >                  names.add(name)
> > +
> >          return self.__diff(
> >              lambda x, y: x is so.NOTRUN and y is not so.NOTRUN,
> >              handler=handler)
> > @@ -147,8 +138,9 @@ class Names(object):
> >      @lazy_property
> >      def disabled(self):
> >          def handler(names, name, prev, cur):
> > -            if name in prev.tests and name not in cur.tests:
> > +            if _result_in(name, prev) and not _result_in(name, cur):
> >                  names.add(name)
> > +
> >          return self.__diff(
> >              lambda x, y: x is not so.NOTRUN and y is so.NOTRUN,
> >              handler=handler)
> > @@ -266,6 +258,17 @@ def escape_pathname(key):
> >      return re.sub(r'[/\\]', '_', key)
> >
> >
> > +def _result_in(name, result):
> > +    """If a result (or a subtest result) exists return True, else False."""
> > +    try:
> > +        # This is a little hacky, but I don't know of a better way where we
> > +        # ensure the value is truthy
> > +        _ = result.get_result(name)
> > +        return True
> > +    except KeyError:
> > +        return False
> > +
> > +
> >  def find_diffs(results, tests, comparator, handler=lambda *a: None):
> >      """Generate diffs between two or more sets of results.
> >
> > @@ -290,7 +293,7 @@ def find_diffs(results, tests, comparator, handler=lambda *a: None):
> >          names = set()
> >          for name in tests:
> >              try:
> > -                if comparator(prev.tests[name].result, cur.tests[name].result):
> > +                if comparator(prev.get_result(name), cur.get_result(name)):
> >                      names.add(name)
> >              except KeyError:
> >                  handler(names, name, prev, cur)
> > @@ -305,7 +308,7 @@ def find_single(results, tests, func):
> >          names = set()
> >          for name in tests:
> >              try:
> > -                if func(res.tests[name].result):
> > +                if func(res.get_result(name)):
> >                      names.add(name)
> >              except KeyError:
> >                  pass
> > diff --git a/framework/tests/summary_console_tests.py b/framework/tests/summary_console_tests.py
> > index 5d9d448..53ecdf1 100644
> > --- a/framework/tests/summary_console_tests.py
> > +++ b/framework/tests/summary_console_tests.py
> > @@ -93,7 +93,7 @@ class Test_print_summary(object):
> >              incomplete=template.format('0', '0'),
> >              dmesg_warn=template.format('0', '0'),
> >              dmesg_fail=template.format('0', '0'),
> > -            changes=template.format('0', '1'),
> > +            changes=template.format('0', '2'),
> >              fixes=template.format('0', '1'),
> >              regressions=template.format('0', '0'),
> >              total=template.format('3', '3')).split('\n')
> > --
> > 2.6.1
> >
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20151020/32280b39/attachment.sig>


More information about the Piglit mailing list