diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 78498f64..9ebb95ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,25 +12,11 @@ jobs: matrix: ruby: ['2.5', '2.6', '2.7', '3.0', '3.1', head, jruby-head] os: [ubuntu-latest, windows-latest] - gemfile: [cucumber_4, cuke_modeler_3_minimum, cuke_modeler_3] task: [spec] include: - ruby: '2.5' # lowest supported version os: ubuntu-latest - gemfile: cuke_modeler_3 # Any one of the gemfiles should be fine task: rubocop - exclude: - # CukeModeler 3.x does not support Ruby 3 until CM 3.6 - - gemfile: cuke_modeler_3_minimum - ruby: jruby-head - - gemfile: cuke_modeler_3_minimum - ruby: head - - gemfile: cuke_modeler_3_minimum - ruby: '3.1' - - gemfile: cuke_modeler_3_minimum - ruby: '3.0' - env: # $BUNDLE_GEMFILE must be set at the job level, so that it is set for all steps - BUNDLE_GEMFILE: ci_gemfiles/${{ matrix.gemfile }}.gemfile steps: - uses: actions/checkout@master - uses: ruby/setup-ruby@v1 diff --git a/.rubocop.yml b/.rubocop.yml index 67bb29d8..7c49c081 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -128,3 +128,7 @@ Style/CaseEquality: Lint/EmptyClass: Enabled: false + +# ENV.fetch('FOO', nil) is the same as ENV['FOO'] +Style/FetchEnvVar: + Enabled: false diff --git a/Gemfile b/Gemfile index df643bd9..5392e329 100644 --- a/Gemfile +++ b/Gemfile @@ -5,4 +5,10 @@ gemspec gem 'bump' gem 'test-unit' gem 'minitest', '~> 5.5.0' +gem 'rspec', '~> 3.3' +gem 'cucumber', "~> 4.0" +gem 'cuke_modeler', '~> 3.6' gem 'spinach', git: "https://github.com/grosser/spinach.git", branch: "grosser/json" # https://github.com/codegram/spinach/pull/229 +gem 'rake' +gem 'rubocop', '~> 1.28.0' # lock minor so we do not get accidental violations, also need to drop ruby 2.5 support to upgrade further +gem 'rubocop-ast', '~> 1.17.0' # also need to drop ruby 2.5 support to remove this line diff --git a/Gemfile.lock b/Gemfile.lock index e61c4be6..cf6b17a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,6 @@ GEM gherkin-ruby (0.3.2) i18n (1.10.0) concurrent-ruby (~> 1.0) - json (2.6.2) middleware (0.1.0) minitest (5.5.1) multi_test (0.1.2) @@ -96,17 +95,16 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.35.1) - json (~> 2.3) + rubocop (1.28.2) parallel (~> 1.10) - parser (>= 3.1.2.1) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.20.1, < 2.0) + rexml + rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.21.0) + rubocop-ast (1.17.0) parser (>= 3.1.1.0) ruby-progressbar (1.11.0) sys-uname (1.2.2) @@ -127,14 +125,15 @@ PLATFORMS DEPENDENCIES bump cucumber (~> 4.0) - cuke_modeler (~> 3.0) + cuke_modeler (~> 3.6) minitest (~> 5.5.0) parallel_tests! rake rspec (~> 3.3) - rubocop + rubocop (~> 1.28.0) + rubocop-ast (~> 1.17.0) spinach! test-unit BUNDLED WITH - 2.3.6 + 2.3.7 diff --git a/Rakefile b/Rakefile index 1409b9f1..d184aff7 100644 --- a/Rakefile +++ b/Rakefile @@ -19,7 +19,7 @@ end desc "bundle all gemfiles [EXTRA=]" task :bundle_all do - extra = ENV.fetch("EXTRA", nil) || "install" + extra = ENV["EXTRA"] || "install" gemfiles = (["Gemfile"] + Dir["spec/fixtures/rails*/Gemfile"]) raise if gemfiles.size < 3 diff --git a/ci_gemfiles/cucumber_4.gemfile b/ci_gemfiles/cucumber_4.gemfile deleted file mode 100644 index fe582868..00000000 --- a/ci_gemfiles/cucumber_4.gemfile +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true -source 'https://rubygems.org' -gemspec path: "../" - -gem 'bump' -gem 'test-unit' -gem 'minitest', '~> 5.5.0' -gem 'spinach', git: "https://github.com/grosser/spinach.git", branch: "grosser/json" # https://github.com/codegram/spinach/pull/229 - -# The version of Cucumber being tested -gem 'cucumber', '~> 4.0' diff --git a/ci_gemfiles/cuke_modeler_3.gemfile b/ci_gemfiles/cuke_modeler_3.gemfile deleted file mode 100644 index 6b817538..00000000 --- a/ci_gemfiles/cuke_modeler_3.gemfile +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true -source 'https://rubygems.org' -gemspec path: "../" - -gem 'bump' -gem 'test-unit' -gem 'minitest', '~> 5.5.0' -gem 'spinach', git: "https://github.com/grosser/spinach.git", branch: "grosser/json" # https://github.com/codegram/spinach/pull/229 - -# The version of CukeModeler being tested -gem 'cuke_modeler', '~> 3.0' diff --git a/ci_gemfiles/cuke_modeler_3_minimum.gemfile b/ci_gemfiles/cuke_modeler_3_minimum.gemfile deleted file mode 100644 index 29440976..00000000 --- a/ci_gemfiles/cuke_modeler_3_minimum.gemfile +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true -source 'https://rubygems.org' -gemspec path: "../" - -gem 'bump' -gem 'test-unit' -gem 'minitest', '~> 5.5.0' -gem 'spinach', git: "https://github.com/grosser/spinach.git", branch: "grosser/json" # https://github.com/codegram/spinach/pull/229 - -# The version of CukeModeler being tested -gem 'cuke_modeler', '3.0.0' diff --git a/lib/parallel_tests.rb b/lib/parallel_tests.rb index b96162be..356ba7ef 100644 --- a/lib/parallel_tests.rb +++ b/lib/parallel_tests.rb @@ -16,7 +16,7 @@ class << self def determine_number_of_processes(count) [ count, - ENV.fetch("PARALLEL_TEST_PROCESSORS", nil), + ENV["PARALLEL_TEST_PROCESSORS"], Parallel.processor_count ].detect { |c| !c.to_s.strip.empty? }.to_i end @@ -68,8 +68,8 @@ def first_process? end def last_process? - current_process_number = ENV.fetch('TEST_ENV_NUMBER', nil) - total_processes = ENV.fetch('PARALLEL_TEST_GROUPS', nil) + current_process_number = ENV['TEST_ENV_NUMBER'] + total_processes = ENV['PARALLEL_TEST_GROUPS'] return true if current_process_number.nil? && total_processes.nil? current_process_number = '1' if current_process_number.nil? current_process_number == total_processes diff --git a/lib/parallel_tests/cli.rb b/lib/parallel_tests/cli.rb index 96daa323..5c3e1864 100644 --- a/lib/parallel_tests/cli.rb +++ b/lib/parallel_tests/cli.rb @@ -383,7 +383,7 @@ def use_colors? end def first_is_1? - val = ENV.fetch("PARALLEL_TEST_FIRST_IS_1", nil) + val = ENV["PARALLEL_TEST_FIRST_IS_1"] ['1', 'true'].include?(val) end @@ -391,7 +391,7 @@ def first_is_1? def simulate_output_for_ci(simulate) if simulate progress_indicator = Thread.new do - interval = Float(ENV.fetch('PARALLEL_TEST_HEARTBEAT_INTERVAL', 60)) + interval = Float(ENV['PARALLEL_TEST_HEARTBEAT_INTERVAL'] || 60) loop do sleep interval print '.' diff --git a/lib/parallel_tests/cucumber/scenarios.rb b/lib/parallel_tests/cucumber/scenarios.rb index 6c95998f..7f9b374e 100644 --- a/lib/parallel_tests/cucumber/scenarios.rb +++ b/lib/parallel_tests/cucumber/scenarios.rb @@ -53,7 +53,7 @@ def split_into_scenarios(files, tags = '') # We loop on each children of the feature test_models = feature.tests - test_models += feature.rules.map(&:tests).flatten if feature.respond_to?(:rules) + test_models += feature.rules.flat_map(&:tests) if feature.respond_to?(:rules) # cuke_modeler >= 3.2 supports rules test_models.each do |test| # It's a scenario, we add it to the scenario_line_logger scenario_line_logger.visit_feature_element(document.path, test, feature_tags, line_numbers: test_lines) diff --git a/lib/parallel_tests/test/runner.rb b/lib/parallel_tests/test/runner.rb index 46e8b62d..317dcac2 100644 --- a/lib/parallel_tests/test/runner.rb +++ b/lib/parallel_tests/test/runner.rb @@ -153,8 +153,8 @@ def command_with_seed(cmd, seed) protected def executable - if ENV.include?('PARALLEL_TESTS_EXECUTABLE') - [ENV.fetch('PARALLEL_TESTS_EXECUTABLE')] + if (executable = ENV['PARALLEL_TESTS_EXECUTABLE']) + [executable] else determine_executable end diff --git a/parallel_tests.gemspec b/parallel_tests.gemspec index 45093e0b..b6d5f3f9 100644 --- a/parallel_tests.gemspec +++ b/parallel_tests.gemspec @@ -17,12 +17,5 @@ Gem::Specification.new name, ParallelTests::VERSION do |s| s.license = "MIT" s.executables = ["parallel_spinach", "parallel_cucumber", "parallel_rspec", "parallel_test"] s.add_runtime_dependency "parallel" - - s.add_development_dependency 'cucumber', '~> 4.0' - s.add_development_dependency 'cuke_modeler', '~> 3.0' - s.add_development_dependency "rake" - s.add_development_dependency 'rspec', '~> 3.3' - s.add_development_dependency "rubocop" - s.required_ruby_version = '>= 2.5.0' end diff --git a/spec/fixtures/rails70/bin/bundle b/spec/fixtures/rails70/bin/bundle index 650643e3..25dfd64d 100755 --- a/spec/fixtures/rails70/bin/bundle +++ b/spec/fixtures/rails70/bin/bundle @@ -18,7 +18,7 @@ m = Module.new do end def env_var_version - ENV.fetch("BUNDLER_VERSION", nil) + ENV["BUNDLER_VERSION"] end def cli_arg_version @@ -38,7 +38,7 @@ m = Module.new do end def gemfile - gemfile = ENV.fetch("BUNDLE_GEMFILE", nil) + gemfile = ENV["BUNDLE_GEMFILE"] return gemfile if gemfile && !gemfile.empty? File.expand_path('../Gemfile', __dir__) diff --git a/spec/parallel_tests/cucumber/scenarios_spec.rb b/spec/parallel_tests/cucumber/scenarios_spec.rb index 88bd42a4..b48b2059 100644 --- a/spec/parallel_tests/cucumber/scenarios_spec.rb +++ b/spec/parallel_tests/cucumber/scenarios_spec.rb @@ -233,12 +233,7 @@ end end - cuke_modeler_version = Gem.loaded_specs['cuke_modeler'].version.version - major = cuke_modeler_version.match(/^(\d+)\./)[1].to_i - minor = cuke_modeler_version.match(/^\d+\.(\d+)\./)[1].to_i - - # CukeModeler doesn't support Rule models until 3.2.0 - context 'with Rules', if: (major > 3) || (minor >= 2) do + context 'with Rules' do # cuke_modeler >=3.2 let(:feature_file) do Tempfile.new('grouper.feature').tap do |feature| feature.write <<-EOS