@@ -76,6 +76,8 @@ def ForRunner(context, templated=False, flavor='IN'):
76
76
77
77
class IfRunner (object ):
78
78
79
+ current_if_stack = []
80
+
79
81
def __init__ (self , context , templated = False ):
80
82
self ._context = context
81
83
self ._templated = templated
@@ -88,6 +90,7 @@ def _get_type(self, data, first, datacondition):
88
90
return data .ELSE_IF_TYPE
89
91
90
92
def run (self , data , name = None ):
93
+ IfRunner .current_if_stack .append (data )
91
94
first = True
92
95
condition_matched = False
93
96
for datacondition , body in data .bodies :
@@ -98,6 +101,7 @@ def run(self, data, name=None):
98
101
runner = StepRunner (self ._context , self ._templated )
99
102
runner .run_steps (body )
100
103
first = False
104
+ IfRunner .current_if_stack .pop ()
101
105
102
106
def _branch_to_be_executed (self , data , first , datacondition , body , condition_matched_already ):
103
107
data_type = self ._get_type (data , first , datacondition )
@@ -121,7 +125,8 @@ def _branch_to_be_executed(self, data, first, datacondition, body, condition_mat
121
125
122
126
def _is_branch_to_execute (self , condition_matched_already , condition_result , body ):
123
127
if self ._context .dry_run :
124
- return True
128
+ current = IfRunner .current_if_stack [- 1 ]
129
+ return current not in IfRunner .current_if_stack [:- 1 ]
125
130
return not condition_matched_already and condition_result and body
126
131
127
132
def _get_name (self , condition ):
0 commit comments