diff --git a/tmt/frameworks/beakerlib.py b/tmt/frameworks/beakerlib.py index 02bb8783ee..5d453e872d 100644 --- a/tmt/frameworks/beakerlib.py +++ b/tmt/frameworks/beakerlib.py @@ -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)] diff --git a/tmt/steps/execute/__init__.py b/tmt/steps/execute/__init__.py index 267fb24e66..1aabfce673 100644 --- a/tmt/steps/execute/__init__.py +++ b/tmt/steps/execute/__init__.py @@ -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, @@ -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. @@ -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)