Skip to content

Commit 8225de2

Browse files
author
Satheesh Rajendran
authored
Merge pull request #204 from narasimhan-v/results_summary_status
Displaying result status in summary
2 parents 81dbe19 + 601e95c commit 8225de2

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

avocado-setup.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import os
1919
import shutil
2020
import time
21+
import json
2122
import sys
2223
import shlex
2324
import argparse
@@ -389,7 +390,13 @@ def run_test(testsuite, avocado_bin):
389390
logger.info('')
390391
result_link = testsuite.jobdir()
391392
if result_link:
392-
result_link += "/job.log"
393+
result_json = result_link + "/results.json"
394+
result_link += "/job.log\n"
395+
with open(result_json, encoding = "utf-8") as fp:
396+
result_state = json.load(fp)
397+
for state in ['pass', 'cancel', 'errors', 'failures', 'skip', 'warn', 'interrupt']:
398+
if state in result_state.keys():
399+
result_link += "| %s %s |" % (state.upper(), str(result_state[state]))
393400
testsuite.runstatus("Run", "Successfully executed", result_link)
394401
else:
395402
testsuite.runstatus("Not_Run", "Unable to find job log file")
@@ -719,13 +726,22 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
719726
if args.interval:
720727
time.sleep(int(args.interval))
721728

729+
# Finding the space needed for formatting result summary
730+
test_name_list = []
731+
for test_suite in Testsuites_list:
732+
test_name_list.append(Testsuites[test_suite].name)
733+
test_name_list.append(Testsuites[Testsuites_list[0]].runlink.split('\n')[0])
734+
test_name_list.append(Testsuites[Testsuites_list[0]].runlink.split('\n')[1])
735+
longest_name_length = len((sorted(test_name_list, key=len)[-1])) + 5
736+
722737
# List the final output
723-
summary_output = ["Summary of test results can be found below:\n%-75s %-10s %-20s" % ('TestSuite', 'TestRun', 'Summary')]
738+
summary_output = ["Summary of test results can be found below:\n%s %s %s" % ('TestSuite'.ljust(longest_name_length),
739+
'TestRun'.ljust(10), 'Summary')]
724740
for test_suite in Testsuites_list:
725741
summary_output.append(' ')
726-
summary_output.append('%-75s %-10s %-20s' % (Testsuites[test_suite].name,
727-
Testsuites[test_suite].run,
728-
Testsuites[test_suite].runsummary))
742+
summary_output.append('%s %s %s' % (Testsuites[test_suite].name.ljust(longest_name_length),
743+
Testsuites[test_suite].run.ljust(10),
744+
Testsuites[test_suite].runsummary))
729745
summary_output.append(Testsuites[test_suite].runlink)
730746
logger.info("\n".join(summary_output))
731747

0 commit comments

Comments
 (0)