Make sure we run finish always
I believe finish step, if enabled, should run always,
even in case of errors.
This way container/VMs will be nicely stopped after the run.
@@ -261,14 +261,19 @@ class Plan(Node):
path=plan_path, content=content,
name='plan', force=force)
- def steps(self, enabled=True, disabled=False, names=False):
+ def steps(self, enabled=True, disabled=False, names=False, without=None):
"""
Iterate over enabled / all steps
Yields instances of all enabled steps by default. Use 'names' to
yield step names only and 'disabled=True' to iterate over all.
+ If you need to skip a step, pass the list of steps to skip via
+ 'without'.
"""
+ without = without or []
for name in tmt.steps.STEPS:
+ if name in without:
+ continue
step = getattr(self, name)
if (enabled and step.enabled or disabled and not step.enabled):
yield name if names else step
@@ -301,9 +306,14 @@ class Plan(Node):
# Wake up all steps
for step in self.steps(disabled=True):
step.wake()
- # Run enabled steps
- for step in self.steps():
+ # Run enabled steps except 'finish'
+ try:
+ for step in self.steps(without=['finish']):
step.go()
+ # Make sure we run 'finish' step always if enabled
+ finally:
+ if self.finish.enabled:
+ self.finish.go()
class Story(Node):
