[Piglit] [PATCH] summary: add a csv output option
Dylan Baker
baker.dylan.c at gmail.com
Wed Oct 1 07:52:22 PDT 2014
I have one style comment, with that fixed:
Reviewed-by: Dylan Baker <baker.dylan.c at gmail.com>
On Wednesday, October 01, 2014 02:56:10 PM Thomas Wood wrote:
> Signed-off-by: Thomas Wood <thomas.wood at intel.com>
> ---
> framework/programs/summary.py | 32 +++++++++++++++++++++++++++++++-
> piglit | 4 ++++
> 2 files changed, 35 insertions(+), 1 deletion(-)
>
> diff --git a/framework/programs/summary.py b/framework/programs/summary.py
> index 81f6d3d..7a008e8 100644
> --- a/framework/programs/summary.py
> +++ b/framework/programs/summary.py
> @@ -22,6 +22,7 @@
> import argparse
> import shutil
> import os.path as path
> +import sys
>
> import framework.summary as summary
> import framework.status as status
> @@ -31,7 +32,8 @@ import framework.junit
>
> __all__ = ['html',
> 'junit',
> - 'console']
> + 'console',
> + 'csv']
>
>
> def html(input_):
> @@ -244,3 +246,31 @@ def console(input_):
> # Generate the output
> output = summary.Summary(args.results)
> output.generate_text(args.diff, args.summary)
> +
> +
> +def csv(input_):
> + parser = argparse.ArgumentParser()
> + parser.add_argument("-o", "--output",
> + metavar="<Output File>",
> + action="store",
> + dest="output",
> + default="stdout",
> + help="Output filename")
> + parser.add_argument("testResults",
> + metavar="<Input Files>",
> + help="JSON results file to be converted")
> + args = parser.parse_args(input_)
> +
> + testrun = framework.results.load_results(args.testResults)
> +
> + def write_results(output):
> + for name, result in testrun.tests.iteritems():
> + output.write("{},{},{},{}\n".format(name, result['time'],
> + result['returncode'],
> + result['result']))
> +
> + if (args.output != "stdout"):
Don't use parenthesis here, its not good python style. Only use parens
when you need to do compound statements.
> + with open(args.output, 'w') as output:
> + write_results(output)
> + else:
> + write_results(sys.stdout)
> diff --git a/piglit b/piglit
> index 8538f81..c1c2520 100755
> --- a/piglit
> +++ b/piglit
> @@ -135,6 +135,10 @@ def main():
> add_help=False,
> help='generate junit xml from results')
> junit.set_defaults(func=summary.junit)
> + csv = summary_parser.add_parser('csv',
> + add_help=False,
> + help='generate csv from results')
> + csv.set_defaults(func=summary.csv)
>
> # Parse the known arguments (piglit run or piglit summary html for
> # example), and then pass the arguments that this parser doesn't know about
> --
> 2.1.0
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20141001/e1c9c8b0/attachment-0001.sig>
More information about the Piglit
mailing list