1- from typing import Optional , TypeVar , cast
1+ from typing import TYPE_CHECKING , Optional , TypeVar , cast
22
33import fmf
44
1919)
2020from tmt .utils .environment import Environment
2121
22+ if TYPE_CHECKING :
23+ from tmt .base .plan import Plan
24+
2225
2326@container
2427class 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 (
0 commit comments