From 9283dc0a537a04bfc7c0e489fff8260a525c4d51 Mon Sep 17 00:00:00 2001 From: subramanya Date: Wed, 31 Jul 2024 18:08:51 +0200 Subject: [PATCH 1/4] add skipretry tag --- atest/02_SuiteWithSkipRetryTest.robot | 11 +++++++++++ atest/run_atest.sh | 2 +- src/RetryFailed/retry_failed.py | 15 +++++++++------ 3 files changed, 21 insertions(+), 7 deletions(-) create mode 100755 atest/02_SuiteWithSkipRetryTest.robot diff --git a/atest/02_SuiteWithSkipRetryTest.robot b/atest/02_SuiteWithSkipRetryTest.robot new file mode 100755 index 0000000..78e1c93 --- /dev/null +++ b/atest/02_SuiteWithSkipRetryTest.robot @@ -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 it should not retry diff --git a/atest/run_atest.sh b/atest/run_atest.sh index 171757c..1e391f9 100755 --- a/atest/run_atest.sh +++ b/atest/run_atest.sh @@ -1 +1 @@ -robot -d results --listener RetryFailed 01_SimpleTestSuite.robot \ No newline at end of file +robot -d results --listener RetryFailed 01_SimpleTestSuite.robot 02_SuiteWithSkipRetryTest.robot \ No newline at end of file diff --git a/src/RetryFailed/retry_failed.py b/src/RetryFailed/retry_failed.py index e31013b..5e93ae5 100644 --- a/src/RetryFailed/retry_failed.py +++ b/src/RetryFailed/retry_failed.py @@ -44,12 +44,15 @@ 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._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 return From ec4c2fb216d93e1962dd2e59d4f5d0b4fbbf898d Mon Sep 17 00:00:00 2001 From: subramanya Date: Wed, 31 Jul 2024 18:12:53 +0200 Subject: [PATCH 2/4] add skip retry tag --- atest/02_SuiteWithSkipRetryTest.robot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atest/02_SuiteWithSkipRetryTest.robot b/atest/02_SuiteWithSkipRetryTest.robot index 78e1c93..ccf50d7 100755 --- a/atest/02_SuiteWithSkipRetryTest.robot +++ b/atest/02_SuiteWithSkipRetryTest.robot @@ -8,4 +8,4 @@ My Simple Test Simple test to skip retry [Tags] test:skipretry - Fail failing this test but it should not retry + Fail failing this test but test should not retry From 78bcb4d33761a5e2ba8c4dc5a9e4da3cf6669ed8 Mon Sep 17 00:00:00 2001 From: subramanya Date: Wed, 31 Jul 2024 18:38:56 +0200 Subject: [PATCH 3/4] add condition to handle global retry --- src/RetryFailed/retry_failed.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/RetryFailed/retry_failed.py b/src/RetryFailed/retry_failed.py index 5e93ae5..7b40388 100644 --- a/src/RetryFailed/retry_failed.py +++ b/src/RetryFailed/retry_failed.py @@ -53,7 +53,9 @@ def start_test(self, test, result): if retry_match: self.max_retries = int(retry_match.group(1)) return - self.max_retries = self._max_retries_by_default + self.max_retries = self._max_retries_by_default + else: + self.max_retries = 0 return def end_test(self, test, result): From 623e571365c5d96c113d25630b3f7b24848da215 Mon Sep 17 00:00:00 2001 From: subramanya Date: Wed, 31 Jul 2024 19:31:53 +0200 Subject: [PATCH 4/4] update read.md --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4841f4e..eda6d91 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +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 \ No newline at end of file