From b666d134caf1d7c028c888e875e77740a96c6ba4 Mon Sep 17 00:00:00 2001 From: Karel Srot Date: Wed, 18 Sep 2024 11:47:02 +0200 Subject: [PATCH] Adjust code to use results_for_tests() --- tmt/steps/report/reportportal.py | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/tmt/steps/report/reportportal.py b/tmt/steps/report/reportportal.py index 0976c946ff..35a1275494 100644 --- a/tmt/steps/report/reportportal.py +++ b/tmt/steps/report/reportportal.py @@ -8,8 +8,7 @@ import tmt.log import tmt.steps.report -from tmt.base import Test -from tmt.result import Result, ResultOutcome +from tmt.result import ResultOutcome from tmt.utils import field, yaml_to_dict if TYPE_CHECKING: @@ -512,28 +511,9 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None: self.verbose("uuid", suite_uuid, "yellow", shift=1) self.data.suite_uuid = suite_uuid - # prepare data for test reporting - # report_queue is a list[tuple(serial_number, result)] - report_queue: list[tuple[int, Optional[Result]]] = [] - tests_executed: set[int] = set() - # collect results per serial_number and populate queue of serial_numbers to report - result: Optional[Result] = None # hint for mypy - for result in self.step.plan.execute.results(): - tests_executed.add(result.serial_number) - report_queue.append((result.serial_number, result)) - # now extend the queue with tests that were not executed - # and populate tests_db - tests_db: dict[int, Test] = {} - test: Optional[Test] = None # hint for mypy - for test in self.step.plan.discover.tests(): - tests_db[test.serial_number] = test - if test.serial_number not in tests_executed: - report_queue.append((test.serial_number, None)) - - # now we can proceed with the actual reporting, we report each serial_number and result - for (serial_number, result) in report_queue: + for result, test in self.step.plan.execute.results_for_tests( + self.step.plan.discover.tests()): test_time = self.time() - test = tests_db.get(serial_number) test_name = None # TODO: for happz, connect Test to Result if possible @@ -541,6 +521,7 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None: item_attributes = attributes.copy() if result: + serial_number = result.serial_number test_name = result.name test_time = result.start_time or self.time() # for multi-host tests store also provision name and role @@ -558,6 +539,7 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None: # update RP item with additional attributes if test details are available if test: + serial_number = test.serial_number if not test_name: test_name = test.name if test.contact: @@ -574,7 +556,6 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None: if not re.search(envar_pattern, key)] if create_test: - if ((self.data.upload_to_launch and launch_per_plan) or self.data.upload_to_suite): test_description = self.append_description(test_description)