diff options
author | Thomas Wood <thomas.wood@intel.com> | 2014-09-24 12:23:24 +0100 |
---|---|---|
committer | Thomas Wood <thomas.wood@intel.com> | 2014-10-01 16:28:27 +0100 |
commit | 73595a9c580026e7f33853c34b8fe98884990597 (patch) | |
tree | 68256ce1beafc1d5adcde364b5234a2e6fa2d22b /framework/programs | |
parent | 1a36e7fd6f162f6056236d83474d099033d1b255 (diff) |
summary: add a csv output option
v2: small style fix (Dylan Baker)
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Reviewed-by: Dylan Baker <baker.dylan.c@gmail.com>
Diffstat (limited to 'framework/programs')
-rw-r--r-- | framework/programs/summary.py | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/framework/programs/summary.py b/framework/programs/summary.py index 81f6d3d86..98b5e66ca 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": + with open(args.output, 'w') as output: + write_results(output) + else: + write_results(sys.stdout) |