Skip to content

Commit

Permalink
Update version support of all cucumber gems (#1751)
Browse files Browse the repository at this point in the history
* Update version support of all cucumber gems

* Fix up failing tests

Don't assume a parent location for default tests
For top level tests, there is no parent

* Strict flag when determining console issues is now a keyword argument

* Fix extra rogue space

* For the fail fast formatter we need to pass in the strict configuration differently

* There are 3 places in the legacy jUnit formatter where we need to pass the strict configuration in a different way

* The pretty formatter has 1 place to update strict configuration handling

* The re-run formatter has 3 instances of situations needing to be fixed up to use correct strict handling

* Refactor to proto world spec

* Enforce minimum of 13.0.1 of core to ensure fix for strict is used

* Fix a missing situation for the cucumber runtime not passing in strict as a kwarg
  • Loading branch information
luke-hill committed Feb 13, 2024
1 parent 1eefe5d commit a4598d9
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
14 changes: 7 additions & 7 deletions cucumber.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.7'
s.required_rubygems_version = '>= 3.0.1'

s.add_dependency 'builder', '~> 3.2', '>= 3.2.4'
s.add_dependency 'cucumber-ci-environment', '~> 9.2', '>= 9.2.0'
s.add_dependency 'cucumber-core', '~> 12.0'
s.add_dependency 'builder', '~> 3.2'
s.add_dependency 'cucumber-ci-environment', '> 9', '< 11'
s.add_dependency 'cucumber-core', '> 13', '< 14'
s.add_dependency 'cucumber-cucumber-expressions', '~> 17.0'
s.add_dependency 'cucumber-gherkin', '> 24', '< 27'
s.add_dependency 'cucumber-gherkin', '> 24', '< 28'
s.add_dependency 'cucumber-html-formatter', '> 20.3', '< 22'
s.add_dependency 'cucumber-messages', '> 19', '< 25'
s.add_dependency 'diff-lcs', '~> 1.5'
s.add_dependency 'mini_mime', '~> 1.1', '>= 1.1.5'
s.add_dependency 'multi_test', '~> 1.1', '>= 1.1.0'
s.add_dependency 'sys-uname', '~> 1.2', '>= 1.2.3'
s.add_dependency 'mini_mime', '~> 1.1'
s.add_dependency 'multi_test', '~> 1.1'
s.add_dependency 'sys-uname', '~> 1.2'

s.add_development_dependency 'cucumber-compatibility-kit', '~> 15.0'
# Only needed whilst we are testing the formatters. Can be removed once we remove tests for those
Expand Down
4 changes: 2 additions & 2 deletions lib/cucumber/formatter/console_issues.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def initialize(config, ast_lookup = AstLookup.new(config))
@config.on_event(:test_case_finished) do |event|
if event.test_case != @previous_test_case
@previous_test_case = event.test_case
@issues[event.result.to_sym] << event.test_case unless event.result.ok?(@config.strict)
@issues[event.result.to_sym] << event.test_case unless event.result.ok?(strict: @config.strict)
elsif event.result.passed?
@issues[:flaky] << event.test_case unless Core::Test::Result::Flaky.ok?(@config.strict.strict?(:flaky))
@issues[:flaky] << event.test_case unless Core::Test::Result::Flaky.ok?(strict: @config.strict.strict?(:flaky))
@issues[:failed].delete(event.test_case)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/formatter/fail_fast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(configuration)
test_case, result = *event.attributes
if test_case != @previous_test_case
@previous_test_case = event.test_case
Cucumber.wants_to_quit = true unless result.ok?(configuration.strict)
Cucumber.wants_to_quit = true unless result.ok?(strict: configuration.strict)
elsif result.passed?
Cucumber.wants_to_quit = false
end
Expand Down
6 changes: 3 additions & 3 deletions lib/cucumber/formatter/junit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def on_test_step_finished(event)
test_step, result = *event.attributes
return if @failing_test_step

@failing_test_step = test_step unless result.ok?(@config.strict)
@failing_test_step = test_step unless result.ok?(strict: @config.strict)
end

def on_test_case_finished(event)
Expand Down Expand Up @@ -111,7 +111,7 @@ def create_output_string(test_case, scenario, result, row_name)
scenario_source = @ast_lookup.scenario_source(test_case)
keyword = scenario_source.type == :Scenario ? scenario_source.scenario.keyword : scenario_source.scenario_outline.keyword
output = "#{keyword}: #{scenario}\n\n"
return output if result.ok?(@config.strict)
return output if result.ok?(strict: @config.strict)

if scenario_source.type == :Scenario
if @failing_test_step
Expand Down Expand Up @@ -140,7 +140,7 @@ def build_testcase(result, scenario_designation, output)
testcase_attributes = get_testcase_attributes(classname, name, duration, filename)

@current_feature_data[:builder].testcase(testcase_attributes) do
if !result.passed? && result.ok?(@config.strict)
if !result.passed? && result.ok?(strict: @config.strict)
@current_feature_data[:builder].skipped
@current_feature_data[:skipped] += 1
elsif !result.passed?
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/formatter/pretty.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def attach(src, media_type, filename)
private

def find_exception_to_be_printed(result)
return nil if result.ok?(options[:strict])
return nil if result.ok?(strict: options[:strict])

result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
exception = result.failed? ? result.exception : result
Expand Down
6 changes: 3 additions & 3 deletions lib/cucumber/formatter/rerun.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ def initialize(config)
config.on_event :test_case_finished do |event|
test_case, result = *event.attributes
if @config.strict.strict?(:flaky)
next if result.ok?(@config.strict)
next if result.ok?(strict: @config.strict)

add_to_failures(test_case)
else
unless @latest_failed_test_case.nil?
if @latest_failed_test_case != test_case
add_to_failures(@latest_failed_test_case)
@latest_failed_test_case = nil
elsif result.ok?(@config.strict)
elsif result.ok?(strict: @config.strict)
@latest_failed_test_case = nil
end
end
@latest_failed_test_case = test_case unless result.ok?(@config.strict)
@latest_failed_test_case = test_case unless result.ok?(strict: @config.strict)
end
end
config.on_event :test_run_finished do
Expand Down
2 changes: 1 addition & 1 deletion lib/cucumber/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def failure?
if @configuration.wip?
summary_report.test_cases.total_passed.positive?
else
!summary_report.ok?(@configuration.strict)
!summary_report.ok?(strict: @configuration.strict)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/cucumber/filters/retry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

let(:configuration) { Cucumber::Configuration.new(retry: 2, retry_total: retry_total) }
let(:retry_total) { Float::INFINITY }
let(:test_case) { Cucumber::Core::Test::Case.new(double, double, [double('test steps')], double, [], double) }
let(:test_case) { Cucumber::Core::Test::Case.new(double, double, [double('test steps')], double, double, [], double) }
let(:receiver) { double('receiver').as_null_object }
let(:filter) { described_class.new(configuration, receiver) }
let(:fail) { Cucumber::Events::AfterTestCase.new(test_case, double('result', failed?: true, ok?: false)) }
Expand Down Expand Up @@ -106,10 +106,10 @@
context 'with too many failing tests' do
let(:retry_total) { 1 }
let(:always_failing_test_case1) do
Cucumber::Core::Test::Case.new(double, double, [double('test steps')], 'test.rb:1', [], double)
Cucumber::Core::Test::Case.new(double, double, [double('test steps')], 'test.rb:1', nil, [], double)
end
let(:always_failing_test_case2) do
Cucumber::Core::Test::Case.new(double, double, [double('test steps')], 'test.rb:9', [], double)
Cucumber::Core::Test::Case.new(double, double, [double('test steps')], 'test.rb:9', nil, [], double)
end

it 'stops retrying tests' do
Expand Down
2 changes: 1 addition & 1 deletion spec/cucumber/formatter/pretty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ module Formatter
Given('this step passes') {}
end

it 'displays hook output appropriately ' do
it 'displays hook output appropriately' do
expect(@out.string).to include <<~OUTPUT
Feature:
Expand Down
8 changes: 4 additions & 4 deletions spec/cucumber/glue/proto_world_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ module Glue
extend Cucumber::Formatter::SpecHelperDsl
include Cucumber::Formatter::SpecHelper

before(:each) do
before do
Cucumber::Term::ANSIColor.coloring = false
@out = StringIO.new
@formatter = Cucumber::Formatter::Pretty.new(actual_runtime.configuration.with_options(out_stream: @out, source: false))
run_defined_feature
end

describe 'when attaching data with null byte' do
define_feature <<-FEATURE
define_feature <<~FEATURE
Feature: Banana party
Scenario: Monkey eats banana
Expand All @@ -154,11 +154,11 @@ module Glue
end

it 'does not report an error' do
expect(@out.string).not_to include 'Error'
expect(@out.string).not_to include('Error')
end

it 'properly attaches the data' do
expect(@out.string).to include "'\x00'attachement"
expect(@out.string).to include("'\x00'attachement")
end
end
end
Expand Down

0 comments on commit a4598d9

Please sign in to comment.