Skip to content

Commit

Permalink
post_run: add report data to 'Results' object/class
Browse files Browse the repository at this point in the history
  • Loading branch information
umarcor committed Oct 28, 2019
1 parent edc7609 commit 74364ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion vunit/ui/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@
UI class Results
"""

from os.path import dirname, join, sep
import re


class Results(object):
"""
Gives access to results after running tests.
"""

def __init__(self, simulator_if):
def __init__(self, output_path, simulator_if, report):
self.output_path = output_path
self._simulator_if = simulator_if
self._report = report

def merge_coverage(self, file_name, args=None):
"""
Expand All @@ -26,3 +31,19 @@ def merge_coverage(self, file_name, args=None):
"""

self._simulator_if.merge_coverage(file_name=file_name, args=args)

def get_report(self):
"""
Get a report (dictionary) of tests: status, time and output path
"""
return {
test.name: {
"status": test._status.name,
"time": test.time,
"path": re.sub(
'^%s' % join(self.output_path, 'test_output') + sep,
'',
dirname(test._output_file_name)
),
}
for test in self._report._test_results_in_order()}
2 changes: 1 addition & 1 deletion vunit/ui/vunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ def _main_run(self, post_run):
report.print_str()

if post_run is not None:
post_run(results=Results(simulator_if))
post_run(results=Results(self._output_path, simulator_if, report))

del simulator_if

Expand Down

0 comments on commit 74364ba

Please sign in to comment.