Skip to content

Commit

Permalink
Parse the subresults for Beakerlib test framework separately
Browse files Browse the repository at this point in the history
  • Loading branch information
seberm committed Sep 25, 2024
1 parent c26e930 commit 428d10b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
11 changes: 10 additions & 1 deletion tmt/frameworks/beakerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,17 @@ def extract_results(
# Finally we have a valid result
else:
actual_result = ResultOutcome.from_spec(result.lower())

# The beakerlib rlPhaseEnd calls the tmt-report-result and generates a
# tmt-report-results.yaml. Propagate these results as subresults to parent result.
# TODO: Somehow handle the test_logs and note from subresults
# TODO: Do we want to propagate the (reduced) actual_outcome from subresults? Probably not.
actual_outcome, test_logs, note, subresults = invocation.phase.extract_tmt_report_subresults(
invocation)

return [tmt.Result.from_test_invocation(
invocation=invocation,
result=actual_result,
note=note,
log=log)]
log=log,
subresult=subresults)]
25 changes: 15 additions & 10 deletions tmt/steps/execute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,12 +757,7 @@ def _process_subresults(

break

return [tmt.Result.from_test_invocation(
invocation=invocation,
result=actual_outcome,
log=test_logs,
note=note,
subresult=subresults)]
return actual_outcome, test_logs, note, subresults

def _process_results_partials(
self,
Expand Down Expand Up @@ -862,7 +857,7 @@ def extract_custom_results(self, invocation: TestInvocation) -> list["tmt.Result

return self._process_results_partials(invocation, collection.results)

def extract_tmt_report_results(self, invocation: TestInvocation) -> list["tmt.Result"]:
def extract_tmt_report_subresults(self, invocation: TestInvocation) -> list["tmt.Result"]:
"""
Extract results from the file generated by ``tmt-report-result`` script.
Expand Down Expand Up @@ -937,9 +932,19 @@ def extract_results(
invocation=invocation,
default_log=invocation.relative_path / TEST_OUTPUT_FILENAME)

# Handle the 'tmt-report-result' command results and save them as tmt subresults
if self._tmt_report_results_filepath(invocation).exists():
return self.extract_tmt_report_results(invocation)
# Handle the 'tmt-report-result' command results and save them as tmt subresults. For
# Beakerlib results, the tmt-report-results.yaml will be always generated. That's why it's
# handled separately by Beakerlib test framework.
if invocation.test.test_framework.__name__ != 'Beakerlib' and self._tmt_report_results_filepath(
invocation).exists():
actual_outcome, test_logs, note, subresults = self.extract_tmt_report_subresults(
invocation)
return [tmt.Result.from_test_invocation(
invocation=invocation,
result=actual_outcome,
note=note,
log=test_logs,
subresult=subresults)]

return invocation.test.test_framework.extract_results(invocation, logger)

Expand Down

0 comments on commit 428d10b

Please sign in to comment.