-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Report will_be_retried from the retry filter's decision #1910
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Cucumber | ||
| # Decides whether a failed test case is run again, honouring both the `--retry` and the `--retry-total` options. | ||
| # | ||
| # The retry filter asks it and then records what it did, the test runner asks it when it reports the outcome of a | ||
| # test case. Both have to get the same answer, so #will_be_retried? never changes the state of the policy. | ||
| class RetryPolicy | ||
| def initialize(max_retries, max_permanent_failures) | ||
| @max_retries = max_retries | ||
| @max_permanent_failures = max_permanent_failures | ||
| @retries = Hash.new(0) | ||
| @permanent_failures = 0 | ||
| end | ||
|
|
||
| def will_be_retried?(test_case, result) | ||
| return false unless result.failed? | ||
| return false if @permanent_failures >= @max_permanent_failures | ||
|
|
||
| @retries[test_case] < @max_retries | ||
| end | ||
|
|
||
| def record_retry(test_case) = @retries[test_case] += 1 | ||
|
|
||
| def record_permanent_failure = @permanent_failures += 1 | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,7 +48,7 @@ def run! | |
| fire_install_plugin_hook | ||
| create_formatters | ||
|
|
||
| receiver = Test::Runner.new(@configuration.event_bus, @configuration.id_generator, Cucumber::Formatter::BacktraceFilter, @configuration.retry_attempts) | ||
| receiver = Test::Runner.new(@configuration.event_bus, @configuration.id_generator, Cucumber::Formatter::BacktraceFilter, @configuration.retry_policy) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self / others. We're baking in more and more complexity here by using posargs. Given we're releasing a breaking change next (And it's already agreed to be big). I think we need to move to kwargs so we can have some mandated and some optional not reliant solely on pos
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My pref. Line above.
|
||
| compile features, receiver, filters, @configuration.event_bus | ||
| fire_after_all_hook unless dry_run? | ||
| @configuration.notify :test_run_finished, !failure? | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we instead lean on our config. I believe this is available in core as well
This is not 100% "known", just a thought. I could be wrong so ignore if I am