[Piglit] [PATCH v2 2/2] framework/summary/common.py: Add enabled, disabled, and skip to changes

Ilia Mirkin imirkin at alum.mit.edu
Wed Oct 21 13:01:03 PDT 2015


On Wed, Oct 21, 2015 at 3:58 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Wed, Oct 21, 2015 at 3:53 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
>> On Wed, Oct 21, 2015 at 02:52:38PM -0400, Ilia Mirkin wrote:
>>> On Wed, Oct 21, 2015 at 2:24 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>>> > On Wed, Oct 21, 2015 at 2:23 PM,  <baker.dylan.c at gmail.com> wrote:
>>> >> From: Dylan Baker <baker.dylan.c at gmail.com>
>>> >>
>>> >> This changes the changes category to include every case were the first
>>> >> status is not the same as the previous status, including
>>> >> <status> <-> notrun, except when <status> is skip.
>>> >>
>>> >> This fixes the failing unit tests from the previous commit.
>>> >>
>>> >> v2: - don't include skip <-> notrun (Ilia)
>>> >>
>>> >> cc: Michel Dänzer <michel at daenzer.net>
>>> >> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
>>> >> ---
>>> >>  framework/summary/common.py | 21 ++++++++++++++++++++-
>>> >>  1 file changed, 20 insertions(+), 1 deletion(-)
>>> >>
>>> >> diff --git a/framework/summary/common.py b/framework/summary/common.py
>>> >> index 95af02a..671a540 100644
>>> >> --- a/framework/summary/common.py
>>> >> +++ b/framework/summary/common.py
>>> >> @@ -101,7 +101,26 @@ class Names(object):
>>> >>
>>> >>      @lazy_property
>>> >>      def changes(self):
>>> >> -        return self.__diff(operator.ne)
>>> >> +        def handler(names, name, prev, cur):
>>> >> +            """Handle missing tests.
>>> >> +
>>> >> +            For changes we want literally anything where the first result
>>> >> +            isn't the same as the second result.
>>> >> +
>>> >> +            """
>>> >> +            def _get(res):
>>> >> +                try:
>>> >> +                    return res.get_result(name)
>>> >> +                except KeyError:
>>> >> +                    return so.NOTRUN
>>> >> +
>>> >> +            # Add any case of a != b except skip <-> notrun
>>> >> +            cur = _get(cur)
>>> >> +            prev = _get(prev)
>>> >> +            if cur != prev and {cur, prev} != {so.SKIP, so.NOTRUN}:
>>> >
>>> > Looks like a python3-ism?
>>>
>>> Or not. Looks like python2.7 added it -- fun. Looks right.
>>>
>>> Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
>>>
>>
>> Yeah, I'm still not sure about how I feel about {} being both the dict
>> and the set brackets. In this case though the terseness lets this fit on
>> one line, and I like that a lot.
>
> If you wanted to be all fancy (aka even more difficult to read), you
> could do something like
>
> if {cur, prev} - {so.SKIP, so.NOTRUN}:
>   asdf
>
> But normally I just do set([...]). I'll have to remember this {} thing.

Er nevermind. This won't actually handle the cur == prev case :) Your
code was fine.

>
>>
>>> >
>>> >> +                names.add(name)
>>> >> +
>>> >> +        return self.__diff(operator.ne, handler=handler)
>>> >>
>>> >>      @lazy_property
>>> >>      def problems(self):
>>> >> --
>>> >> 2.6.1
>>> >>
>>> >> _______________________________________________
>>> >> Piglit mailing list
>>> >> Piglit at lists.freedesktop.org
>>> >> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list