Commit 3707d1ad authored by Rafael Antognolli's avatar Rafael Antognolli

framework: Add new formatted summary.

Similarly to print-cmd, this option allows one to specify a format
string to output each test in the summary. It can be used to easily
generate a list of only tests that failed, with something like:

./piglit summary formatted -e pass -e skip -e notrun --format {name} \
      results.json.bz2 > ../piglit-summary.txt

This file can then be used as input to piglit run --test-list.

v2: Fix typo and s/testResults/test_results/ (Dylan)
Signed-off-by: Rafael Antognolli's avatarRafael Antognolli <rafael.antognolli@intel.com>
Reviewed-by: Dylan Baker's avatarDylan Baker <dylan@pnwbakers.com>
parent 827d3743
......@@ -40,6 +40,7 @@ __all__ = [
'csv',
'html',
'feature'
'formatted'
]
......@@ -122,7 +123,7 @@ def console(input_):
"""Combine files in a tests/ directory into a single results file."""
unparsed = parsers.parse_config(input_)[1]
# Adding the parent is necissary to get the help options
# Adding the parent is necessary to get the help options
parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
# Set the -d and -s options as exclusive, since it's silly to call for diff
......@@ -200,6 +201,61 @@ def csv(input_):
else:
write_results(sys.stdout)
@exceptions.handler
def formatted(input_):
# Make a copy of the status text list and add all. This is used as the
# argument list for -e/--exclude
statuses = set(str(s) for s in status.ALL)
unparsed = parsers.parse_config(input_)[1]
# Adding the parent is necissary to get the help options
parser = argparse.ArgumentParser(parents=[parsers.CONFIG])
parser.add_argument("--format",
dest="format_string",
metavar="<format string>",
default="{name} ::: {time} ::: "
"{returncode} ::: {result}",
action="store",
help="A template string that defines the format. "
"Replacement tokens are {name}, {time}, "
"{returncode} and {result}")
parser.add_argument("-e", "--exclude-details",
default=[],
action="append",
choices=statuses,
help="Optionally exclude the listing of tests with "
"the status(es) given as arguments. "
"May be used multiple times")
parser.add_argument("-o", "--output",
metavar="<Output File>",
action="store",
dest="output",
default="stdout",
help="Output filename")
parser.add_argument("test_results",
metavar="<Input Files>",
help="JSON results file to be converted")
args = parser.parse_args(unparsed)
testrun = backends.load(args.test_results)
def write_results(output):
for name, result in six.iteritems(testrun.tests):
if result.result in args.exclude_details:
continue
output.write((args.format_string + "\n").format(
name=name,
time=result.time.total,
returncode=result.returncode,
result=result.result))
if args.output != "stdout":
with open(args.output, 'w') as output:
write_results(output)
else:
write_results(sys.stdout)
@exceptions.handler
def aggregate(input_):
......
......@@ -149,6 +149,10 @@ def main():
add_help=False,
help='generate csv from results')
csv.set_defaults(func=summary.csv)
formatted = summary_parser.add_parser('formatted',
add_help=False,
help='generate formatted output from results')
formatted.set_defaults(func=summary.formatted)
aggregate = summary_parser.add_parser('aggregate',
add_help=False,
help="Aggregate incomplete piglit run.")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment