Skip to content

Commit 6474508

Browse files
committed
if dryrun: stop when recursing to same if statement
1 parent 87d109e commit 6474508

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/robot/running/steprunner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def ForRunner(context, templated=False, flavor='IN'):
7676

7777
class IfRunner(object):
7878

79+
current_if_stack = []
80+
7981
def __init__(self, context, templated=False):
8082
self._context = context
8183
self._templated = templated
@@ -88,6 +90,7 @@ def _get_type(self, data, first, datacondition):
8890
return data.ELSE_IF_TYPE
8991

9092
def run(self, data, name=None):
93+
IfRunner.current_if_stack.append(data)
9194
first = True
9295
condition_matched = False
9396
for datacondition, body in data.bodies:
@@ -98,6 +101,7 @@ def run(self, data, name=None):
98101
runner = StepRunner(self._context, self._templated)
99102
runner.run_steps(body)
100103
first = False
104+
IfRunner.current_if_stack.pop()
101105

102106
def _branch_to_be_executed(self, data, first, datacondition, body, condition_matched_already):
103107
data_type = self._get_type(data, first, datacondition)
@@ -121,7 +125,8 @@ def _branch_to_be_executed(self, data, first, datacondition, body, condition_mat
121125

122126
def _is_branch_to_execute(self, condition_matched_already, condition_result, body):
123127
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]
125130
return not condition_matched_already and condition_result and body
126131

127132
def _get_name(self, condition):

0 commit comments

Comments
 (0)