Skip to content

Commit 3eed02a

Browse files
committed
display report plugin shall now include finish phases
1 parent e3f4b1a commit 3eed02a

3 files changed

Lines changed: 49 additions & 7 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
description:
2+
The :py:ref:`/plugins/report/display` report plugin will now
3+
report results of the ``finish`` step as well as tests and the
4+
``prepare`` results.

tmt/steps/finish/__init__.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Optional, TypeVar, cast
1+
from typing import TYPE_CHECKING, Optional, TypeVar, cast
22

33
import fmf
44

@@ -19,6 +19,9 @@
1919
)
2020
from tmt.utils.environment import Environment
2121

22+
if TYPE_CHECKING:
23+
from tmt.base.plan import Plan
24+
2225

2326
@container
2427
class FinishStepData(tmt.steps.WhereableStepData, tmt.steps.StepData):
@@ -63,6 +66,8 @@ class Finish(tmt.steps.StepWithQueue[FinishStepData, PluginOutcome]):
6366

6467
_plugin_base_class = FinishPlugin
6568

69+
results: list[PhaseResult]
70+
6671
@property
6772
def _preserved_workdir_members(self) -> set[str]:
6873
"""
@@ -81,6 +86,32 @@ def _preserved_workdir_members(self) -> set[str]:
8186

8287
return members
8388

89+
def __init__(
90+
self,
91+
*,
92+
plan: 'Plan',
93+
raw_data: list[tmt.steps._RawStepData],
94+
logger: tmt.log.Logger,
95+
) -> None:
96+
"""
97+
Initialize finish step data
98+
"""
99+
100+
super().__init__(plan=plan, raw_data=raw_data, logger=logger)
101+
102+
self.results = []
103+
self.finalizations_applied = 0
104+
105+
def load(self) -> None:
106+
super().load()
107+
108+
self.results = self._load_results(PhaseResult, allow_missing=True)
109+
110+
def save(self) -> None:
111+
super().save()
112+
113+
self._save_results(self.results)
114+
84115
def wake(self) -> None:
85116
"""
86117
Wake up the step (process workdir and command line)
@@ -153,7 +184,7 @@ def go(self, force: bool = False) -> None:
153184
],
154185
)
155186

156-
results: list[PhaseResult] = []
187+
self.results: list[PhaseResult] = []
157188
exceptions: list[Exception] = []
158189

159190
def _record_exception(
@@ -166,7 +197,7 @@ def _record_exception(
166197
def _is_failed() -> bool:
167198
return bool(exceptions) or any(
168199
result.result in (ResultOutcome.ERROR, ResultOutcome.FAIL)
169-
for result in results
200+
for result in self.results
170201
)
171202

172203
for outcome in self._queue.run():
@@ -186,7 +217,7 @@ def _is_failed() -> bool:
186217

187218
_record_exception(outcome, outcome.exc)
188219

189-
results.append(
220+
self.results.append(
190221
PhaseResult(
191222
name=outcome.phase.name,
192223
result=ResultOutcome.ERROR,
@@ -206,7 +237,7 @@ def _is_failed() -> bool:
206237
# log them and save them, but do not emit any special result.
207238
# Plugin was alive till the very end, and returned results.
208239
if outcome.result:
209-
results += outcome.result.results
240+
self.results += outcome.result.results
210241

211242
if outcome.result.exceptions:
212243
for exc in outcome.result.exceptions:
@@ -219,7 +250,7 @@ def _is_failed() -> bool:
219250

220251
break
221252

222-
self._save_results(results)
253+
self._save_results(self.results)
223254

224255
if _is_failed():
225256
raise tmt.utils.GeneralError(

tmt/steps/report/display.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ class ReportDisplay(tmt.steps.report.ReportPlugin[ReportDisplayData]):
308308
Show results on the terminal.
309309
310310
Give a concise summary of results produced by tests and ``prepare``
311-
phases, directly on the terminal.
311+
and ``finish`` phases, directly on the terminal.
312312
313313
Allows to select the desired level of verbosity:
314314
@@ -389,3 +389,10 @@ def go(self, *, logger: Optional[tmt.log.Logger] = None) -> None:
389389
display_guest,
390390
logger,
391391
)
392+
393+
self._print_step_results(
394+
self.step.plan.finish,
395+
self.step.plan.finish.results,
396+
display_guest,
397+
logger,
398+
)

0 commit comments

Comments
 (0)