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

error code 0 on successful --retry #1121

Closed
wants to merge 4 commits into from
Closed
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
6 changes: 6 additions & 0 deletions lib/cucumber/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def self.default
# @method on_event
def_instance_delegator :event_bus, :on, :on_event

attr_writer :total_cases

# @private
def notify(message, *args)
event_bus.send(message, *args)
Expand Down Expand Up @@ -67,6 +69,10 @@ def retry_attempts
@options[:retry]
end

def total_cases
@total_cases ||= 0
end

def guess?
@options[:guess]
end
Expand Down
1 change: 1 addition & 0 deletions lib/cucumber/filters/retry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Filters
class Retry < Core::Filter.new(:configuration)

def test_case(test_case)
configuration.total_cases += 1
configuration.on_event(:test_case_finished) do |event|
next unless retry_required?(test_case, event)

Expand Down
9 changes: 9 additions & 0 deletions lib/cucumber/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ def legacy_formatter?(factory)
def failure?
if @configuration.wip?
summary_report.test_cases.total_passed > 0
elsif @configuration.retry_attempts > 0
if summary_report.test_cases.total_passed == @configuration.total_cases
Cucumber.logger.info "All retried test cases passed!\n" if summary_report.test_cases.total_failed > 0
false
else
true
end
else
summary_report.test_cases.total_failed > 0 || summary_report.test_steps.total_failed > 0 ||
(@configuration.strict? && (summary_report.test_steps.total_undefined > 0 || summary_report.test_steps.total_pending > 0))
Expand All @@ -246,6 +253,8 @@ def filters
filters << Cucumber::Core::Test::NameFilter.new(name_regexps)
filters << Cucumber::Core::Test::LocationsFilter.new(filespecs.locations)
filters << Filters::Randomizer.new(@configuration.seed) if @configuration.randomize?
filters << Filters::Quit.new
filters << Filters::Retry.new(@configuration)
# TODO: can we just use Glue::RegistryAndMore's step definitions directly?
step_match_search = StepMatchSearch.new(@support_code.registry.method(:step_matches), @configuration)
filters << Filters::ActivateSteps.new(step_match_search, @configuration)
Expand Down