Skip to content

Commit 3c5f7c6

Browse files
committed
Fix keyword timeout in teardown when keyword uses WUKS.
This was a regression caused by #3398. Fixes #5237.
1 parent de07bff commit 3c5f7c6

File tree

3 files changed

+61
-11
lines changed

3 files changed

+61
-11
lines changed

atest/robot/running/failures_in_teardown.robot

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,34 @@ Execution Stops After Keyword Timeout
2929
Length Should Be ${tc.teardown.kws} 2
3030
Should Be Equal ${tc.teardown.kws[-1].status} NOT RUN
3131

32-
Execution Continues After Keyword Timeout Occurs In Executed Keyword
32+
Execution continues if executed keyword fails for keyword timeout
3333
${tc} = Check Test Case ${TESTNAME}
34-
Length Should Be ${tc.teardown.body} 2
35-
Length Should Be ${tc.teardown.body[0].body} 2
36-
Should Be Equal ${tc.teardown.body[0].body[0].status} FAIL
37-
Should Be Equal ${tc.teardown.body[0].body[1].status} NOT RUN
38-
Should Be Equal ${tc.teardown.body[0].status} FAIL
39-
Should Be Equal ${tc.teardown.body[1].status} FAIL
34+
Length Should Be ${tc.teardown.body} 2
35+
Should Be Equal ${tc.teardown.body[0].status} FAIL
36+
Should Be Equal ${tc.teardown.body[1].status} FAIL
37+
Length Should Be ${tc.teardown.body[0].body} 2
38+
Should Be Equal ${tc.teardown.body[0].body[0].status} FAIL
39+
Check Log Message ${tc.teardown.body[0].body[0].body[0]} Keyword timeout 42 milliseconds exceeded. FAIL
40+
Should Be Equal ${tc.teardown.body[0].body[1].status} NOT RUN
41+
Length Should Be ${tc.teardown.body[1].body} 1
42+
Check Log Message ${tc.teardown.body[1].body[0]} This should be executed FAIL
43+
44+
Execution stops after keyword timeout if keyword uses WUKS
45+
${tc} = Check Test Case ${TESTNAME}
46+
Length Should Be ${tc.teardown.body} 2
47+
Should Be Equal ${tc.teardown.body[0].status} FAIL
48+
Should Be Equal ${tc.teardown.body[1].status} NOT RUN
49+
Length Should Be ${tc.teardown.body[0].body} 2
50+
Should Be Equal ${tc.teardown.body[0].body[0].status} FAIL
51+
Should Be Equal ${tc.teardown.body[0].body[1].status} FAIL
52+
Length Should Be ${tc.teardown.body[0].body[0].body} 2
53+
Should Be Equal ${tc.teardown.body[0].body[0].body[0].status} PASS
54+
Should Be Equal ${tc.teardown.body[0].body[0].body[1].status} FAIL
55+
Check Log Message ${tc.teardown.body[0].body[0].body[1].body[0]} Failing! FAIL
56+
Length Should Be ${tc.teardown.body[0].body[1].body} 2
57+
Should Be Equal ${tc.teardown.body[0].body[1].body[0].status} FAIL
58+
Check Log Message ${tc.teardown.body[0].body[1].body[0].body[0]} Keyword timeout 100 milliseconds exceeded. FAIL
59+
Should Be Equal ${tc.teardown.body[0].body[1].body[1].status} NOT RUN
4060

4161
Execution Continues If Variable Does Not Exist
4262
${tc} = Check Test Case ${TESTNAME}

atest/testdata/running/failures_in_teardown.robot

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Failure When Setting Variables
4343
No Operation
4444
[Teardown] Failure when setting variables
4545

46-
Failure In For Loop
46+
Failure In FOR Loop
4747
[Documentation] FAIL Teardown failed:
4848
... Several failures occurred:
4949
...
@@ -57,7 +57,7 @@ Failure In For Loop
5757
...
5858
... ${SUITE TEARDOWN FAILED}
5959
No Operation
60-
[Teardown] Failures In For Loop
60+
[Teardown] Failures In FOR Loop
6161

6262
Execution Continues After Test Timeout
6363
[Documentation] FAIL Teardown failed:
@@ -76,7 +76,7 @@ Execution Stops After Keyword Timeout
7676
No Operation
7777
[Teardown] Keyword Timeout Occurs
7878

79-
Execution Continues After Keyword Timeout Occurs In Executed Keyword
79+
Execution continues if executed keyword fails for keyword timeout
8080
[Documentation] FAIL Teardown failed:
8181
... Several failures occurred:
8282
...
@@ -88,6 +88,14 @@ Execution Continues After Keyword Timeout Occurs In Executed Keyword
8888
No Operation
8989
[Teardown] Keyword Timeout Occurs In Executed Keyword
9090

91+
Execution stops after keyword timeout if keyword uses WUKS
92+
[Documentation] FAIL Teardown failed:
93+
... Keyword timeout 100 milliseconds exceeded.
94+
...
95+
... ${SUITE TEARDOWN FAILED}
96+
No Operation
97+
[Teardown] Keyword Using WUKS
98+
9199
Execution Continues If Variable Does Not Exist
92100
[Documentation] FAIL Teardown failed:
93101
... Several failures occurred:
@@ -150,7 +158,7 @@ Failure when setting variables
150158
${ret} = Fail Return values is None
151159
Should Be Equal ${ret} ${None}
152160

153-
Failures In For Loop
161+
Failures In FOR Loop
154162
FOR ${animal} IN cat dog
155163
Fail ${animal}
156164
Fail again
@@ -169,6 +177,16 @@ Keyword Timeout Occurs In Executed Keyword
169177
Keyword Timeout Occurs
170178
Fail This should be executed
171179

180+
Keyword Using WUKS
181+
[Timeout] 100ms
182+
Wait Until Keyword Succeeds 4x 1s
183+
... Fail Slowly
184+
Fail This should not be executed
185+
186+
Fail Slowly
187+
Sleep 0.51ms
188+
Fail Failing!
189+
172190
Missing Variables
173191
Log ${this var does not exist}
174192
Log This should be executed

src/robot/libraries/BuiltIn.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2415,6 +2415,7 @@ def wait_until_keyword_succeeds(self, retry, retry_interval, name, *args):
24152415
try:
24162416
return self.run_keyword(name, *args)
24172417
except ExecutionFailed as err:
2418+
self._reset_keyword_timeout_in_teardown(err, self._context)
24182419
if err.dont_continue or err.skip:
24192420
raise
24202421
count -= 1
@@ -2434,6 +2435,17 @@ def wait_until_keyword_succeeds(self, retry, retry_interval, name, *args):
24342435
)
24352436
self._sleep_in_parts(sleep_time)
24362437

2438+
def _reset_keyword_timeout_in_teardown(self, err, context):
2439+
# Keyword timeouts in teardowns have been converted to normal failures
2440+
# to allow execution to continue on higher level:
2441+
# https://github.com/robotframework/robotframework/issues/3398
2442+
# We need to reset it here to not continue unnecessarily:
2443+
# https://github.com/robotframework/robotframework/issues/5237
2444+
if context.in_teardown:
2445+
timeouts = [t for t in context.timeouts if t.type == 'Keyword']
2446+
if timeouts and min(timeouts).timed_out():
2447+
err.keyword_timeout = True
2448+
24372449
@run_keyword_variant(resolve=1)
24382450
def set_variable_if(self, condition, *values):
24392451
"""Sets variable based on the given condition.

0 commit comments

Comments
 (0)