Skip to content

Commit 87d109e

Browse files
committed
recursing if dryrun
1 parent cbc7a91 commit 87d109e

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

atest/robot/cli/dryrun/if.robot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Test Teardown Last keyword should have been validated
44
Resource dryrun_resource.robot
55

66
*** Test Cases ***
7-
IF is not executed in dry run
7+
IF will not recurse in dry run
88
Check Test Case ${TESTNAME}
99

10-
ELSE IF is not executed in dry run
10+
ELSE IF will not recurse in dry run
1111
Check Test Case ${TESTNAME}
1212

13-
ELSE is not executed in dry run
13+
ELSE will not recurse in dry run
1414
Check Test Case ${TESTNAME}
1515

1616
Dryrun fail inside of IF

atest/testdata/cli/dryrun/if.robot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
Resource resource.robot
33

44
*** Test Cases ***
5-
IF is not executed in dry run
5+
IF will not recurse in dry run
66
Recursive if call again
77
This is validated
88

9-
ELSE IF is not executed in dry run
9+
ELSE IF will not recurse in dry run
1010
Recursive else if call again
1111
This is validated
1212

13-
ELSE is not executed in dry run
13+
ELSE will not recurse in dry run
1414
Recursive else call again
1515
This is validated
1616

src/robot/running/steprunner.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,22 +103,27 @@ def _branch_to_be_executed(self, data, first, datacondition, body, condition_mat
103103
data_type = self._get_type(data, first, datacondition)
104104
condition_result = data_type == data.ELSE_TYPE
105105
unresolved_condition = ''
106-
if self._context.dry_run:
107-
condition_matched_already = True
108106
if not condition_result:
109107
unresolved_condition = datacondition[0]
110-
if not condition_matched_already:
108+
if not condition_matched_already and not self._context.dry_run:
111109
condition, _ = VariableReplacer().replace([unresolved_condition], (), variables=self._context.variables)
112110
resolved_condition = condition[0]
113111
if is_unicode(resolved_condition):
114112
condition_result = evaluate_expression(resolved_condition, self._context.variables)
115113
else:
116114
condition_result = bool(resolved_condition)
117-
branch_to_execute = not condition_matched_already and condition_result and body
115+
branch_to_execute = self._is_branch_to_execute(condition_matched_already,
116+
condition_result,
117+
body)
118118
result = KeywordResult(kwname=self._get_name(unresolved_condition),
119119
type=data_type)
120120
return branch_to_execute, result
121121

122+
def _is_branch_to_execute(self, condition_matched_already, condition_result, body):
123+
if self._context.dry_run:
124+
return True
125+
return not condition_matched_already and condition_result and body
126+
122127
def _get_name(self, condition):
123128
if not condition:
124129
return ''

0 commit comments

Comments
 (0)