Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skip retry tag #9

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,15 @@ Example:
[Tags] test:retry(2)
Log This test will be retried 2 times if it fails

Tagging tasks by `task:retry(3)` should also work.
Tagging tasks by `task:retry(3)` should also work.

### Skip retry for some tests

Skip retry for some tests in a testsuite

Example:

*** Test Cases ***
Test Case
[Tags] test:skipretry
Log This test will be skipped for retry if it fails
11 changes: 11 additions & 0 deletions atest/02_SuiteWithSkipRetryTest.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*** Settings ***
Test Tags test:retry(1)

*** Test Cases ***
My Simple Test
Log Hello World
Should Be Equal Hello Hello

Simple test to skip retry
[Tags] test:skipretry
Fail failing this test but test should not retry
2 changes: 1 addition & 1 deletion atest/run_atest.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
robot -d results --listener RetryFailed 01_SimpleTestSuite.robot
robot -d results --listener RetryFailed 01_SimpleTestSuite.robot 02_SuiteWithSkipRetryTest.robot
19 changes: 12 additions & 7 deletions src/RetryFailed/retry_failed.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,18 @@ def start_test(self, test, result):
if self.retries:
BuiltIn().set_test_variable("${RETRYFAILED_RETRY_INDEX}", self.retries)
if self.log_level is not None:
self._original_log_level = BuiltIn()._context.output.set_log_level(self.log_level)
for tag in test.tags:
retry_match = re.match(r"(?:test|task):retry\((\d+)\)", tag)
if retry_match:
self.max_retries = int(retry_match.group(1))
return
self.max_retries = self._max_retries_by_default
self._original_log_level = BuiltIn()._context.output.set_log_level(self.log_level)

skip_tags = {"test:skipretry", "task:skipretry"}
if not skip_tags.intersection(test.tags):
for tag in test.tags:
retry_match = re.match(r"(?:test|task):retry\((\d+)\)", tag)
if retry_match:
self.max_retries = int(retry_match.group(1))
return
self.max_retries = self._max_retries_by_default
else:
self.max_retries = 0
return

def end_test(self, test, result):
Expand Down