[Piglit] [PATCH 3/4] framework/summary.py: move text summary printer into a helper

Ilia Mirkin imirkin at alum.mit.edu
Mon May 11 15:00:41 PDT 2015


On Mon, May 11, 2015 at 5:57 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> This allows the incomplete option to not print a summary.
>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
>  framework/summary.py | 42 ++++++++++++++++++++++++------------------
>  1 file changed, 24 insertions(+), 18 deletions(-)
>
> diff --git a/framework/summary.py b/framework/summary.py
> index 5b9ba9a..d133aca 100644
> --- a/framework/summary.py
> +++ b/framework/summary.py
> @@ -574,29 +574,35 @@ class Summary:
>                      statuses=' '.join(str(i.tests.get(test, {'result': so.SKIP})
>                                            ['result']) for i in self.results)))
>
> +        def print_summary():
> +            """print a summary."""
> +            print("summary:\n"
> +                  "       pass: {pass}\n"
> +                  "       fail: {fail}\n"
> +                  "      crash: {crash}\n"
> +                  "       skip: {skip}\n"
> +                  "    timeout: {timeout}\n"
> +                  "       warn: {warn}\n"
> +                  " incomplete: {incomplete}\n"
> +                  " dmesg-warn: {dmesg-warn}\n"
> +                  " dmesg-fail: {dmesg-fail}".format(**self.totals))
> +            if self.tests['changes']:

I never know how these inner functions work... can you confirm that
'self' points to the right thing with this?

> +                print("    changes: {changes}\n"
> +                      "      fixes: {fixes}\n"
> +                      "regressions: {regressions}".format(
> +                          **{k: len(v) for k, v in self.tests.iteritems()}))
> +
> +            print("      total: {}".format(sum(self.totals.itervalues())))
> +
>          # Print the name of the test and the status from each test run
>          if mode == 'all':
>              printer(self.tests['all'])
> +            print_summary()
>          elif mode == 'diff':
>              printer(self.tests['changes'])
> +            print_summary()
>          elif mode == 'incomplete':
>              printer(self.tests['incomplete'])
> +        elif mode == 'summary':
> +            print_summary()
>
> -        # Print the summary
> -        print("summary:\n"
> -              "       pass: {pass}\n"
> -              "       fail: {fail}\n"
> -              "      crash: {crash}\n"
> -              "       skip: {skip}\n"
> -              "    timeout: {timeout}\n"
> -              "       warn: {warn}\n"
> -              " incomplete: {incomplete}\n"
> -              " dmesg-warn: {dmesg-warn}\n"
> -              " dmesg-fail: {dmesg-fail}".format(**self.totals))
> -        if self.tests['changes']:
> -            print("    changes: {changes}\n"
> -                  "      fixes: {fixes}\n"
> -                  "regressions: {regressions}".format(
> -                      **dict((k, len(v)) for k, v in self.tests.iteritems())))
> -
> -        print("      total: {}".format(sum(self.totals.itervalues())))
> --
> 2.4.0
>


More information about the Piglit mailing list