From 9fd54b73bc6245867a7c9d5f94bea9b7fd3dcb0f Mon Sep 17 00:00:00 2001 From: hoffi Date: Mon, 20 Aug 2018 18:49:49 +0200 Subject: [PATCH 1/3] $CHILD_STATUS returns an ExitStatus-Object describing a 2-byte integer. Used directly with Kernel#exit, this will result in unexpected behaviour. Providing a value of 256 will result in exit code 0 which is not appropriate. Co-authored-by: Sven Winkler --- lib/zeus/parallel_tests/worker.rb | 3 ++- spec/lib/zeus/parallel_tests/worker_spec.rb | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/zeus/parallel_tests/worker.rb b/lib/zeus/parallel_tests/worker.rb index e340534..21a232a 100644 --- a/lib/zeus/parallel_tests/worker.rb +++ b/lib/zeus/parallel_tests/worker.rb @@ -1,5 +1,6 @@ require_relative '../parallel_tests' require 'tempfile' +require 'English' module Zeus module ParallelTests @@ -22,7 +23,7 @@ def initialize(suite, env, argv) def spawn system %(zeus parallel_#{@suite}_worker #{parallel_tests_attributes}) args_file.unlink - $CHILD_STATUS.to_i + ($CHILD_STATUS && $CHILD_STATUS.exitstatus) || 1 end private diff --git a/spec/lib/zeus/parallel_tests/worker_spec.rb b/spec/lib/zeus/parallel_tests/worker_spec.rb index f3f2036..4166345 100644 --- a/spec/lib/zeus/parallel_tests/worker_spec.rb +++ b/spec/lib/zeus/parallel_tests/worker_spec.rb @@ -6,7 +6,7 @@ let(:cli_env) { { 'TEST_ENV_NUMBER' => '3' } } let(:worker) { double('worker', spawn: 0) } before { allow(Zeus::ParallelTests::Worker).to receive_messages(new: worker) } - subject { Zeus::ParallelTests::Worker.run(cli_argv, cli_env) } + subject { Zeus::ParallelTests::Worker.run(cli_argv, cli_env) } it 'creates instance of worker' do expect(Zeus::ParallelTests::Worker).to receive(:new) @@ -51,10 +51,16 @@ subject end - it 'returns exit code' do - system 'true' - expect(worker).to receive(:system) { allow($CHILD_STATUS).to receive_messages(to_i: 1) } + it 'returns exit code 1 as fallback' do + allow_any_instance_of(Process::Status) + .to receive_messages(exitstatus: nil) expect(subject).to eq(1) end + + it 'returns the original exit code of the command' do + allow_any_instance_of(Process::Status) + .to receive_messages(exitstatus: 128) + expect(subject).to eq(128) + end end end From 94181b4ce36565a75cc1b754ad6e35f659404180 Mon Sep 17 00:00:00 2001 From: hoffi Date: Mon, 20 Aug 2018 18:55:59 +0200 Subject: [PATCH 2/3] Fixed dependency versions to work in all supported ruby versions --- zeus-parallel_tests.gemspec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/zeus-parallel_tests.gemspec b/zeus-parallel_tests.gemspec index cc52605..74ab644 100644 --- a/zeus-parallel_tests.gemspec +++ b/zeus-parallel_tests.gemspec @@ -24,13 +24,15 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'appraisal' spec.add_development_dependency 'bundler' spec.add_development_dependency 'rake' - spec.add_development_dependency 'rubocop' + spec.add_development_dependency 'rubocop', '<= 0.35.1' spec.add_development_dependency 'rspec', '>= 3.0' # Gems used by dummy app in testing. - spec.add_development_dependency 'cucumber-rails' + spec.add_development_dependency 'cucumber-core', '<= 3.0.0' + spec.add_development_dependency 'cucumber-rails', '<= 1.5.0' spec.add_development_dependency 'database_cleaner' spec.add_development_dependency 'guard-rspec' + spec.add_development_dependency 'rainbow', '<= 2.2.2' spec.add_development_dependency 'rspec-rails' spec.add_development_dependency 'sqlite3' end From 3a50e790862f607bc9c78ce739a000a23b862cda Mon Sep 17 00:00:00 2001 From: hoffi Date: Mon, 20 Aug 2018 18:56:29 +0200 Subject: [PATCH 3/3] Fixed rubocop warnings --- gemfiles/rails_3_zeus_0.13.gemfile | 2 +- gemfiles/rails_3_zeus_0.15.gemfile | 2 +- gemfiles/rails_4_zeus_0.13.gemfile | 2 +- gemfiles/rails_4_zeus_0.15.gemfile | 2 +- spec/dummy/Guardfile | 20 ++++++++++---------- spec/dummy/config.ru | 2 +- spec/dummy/config/environments/test.rb | 4 ++-- spec/dummy/script/rails | 4 ++-- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gemfiles/rails_3_zeus_0.13.gemfile b/gemfiles/rails_3_zeus_0.13.gemfile index 87a137c..45a6e75 100644 --- a/gemfiles/rails_3_zeus_0.13.gemfile +++ b/gemfiles/rails_3_zeus_0.13.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "rails", "3.2.21" gem "zeus", "0.13.3" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_3_zeus_0.15.gemfile b/gemfiles/rails_3_zeus_0.15.gemfile index 5cf710a..f0c0665 100644 --- a/gemfiles/rails_3_zeus_0.15.gemfile +++ b/gemfiles/rails_3_zeus_0.15.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "rails", "3.2.21" gem "zeus", "0.15.4" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_4_zeus_0.13.gemfile b/gemfiles/rails_4_zeus_0.13.gemfile index 42da9b5..e4967ab 100644 --- a/gemfiles/rails_4_zeus_0.13.gemfile +++ b/gemfiles/rails_4_zeus_0.13.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "rails", "4.2.3" gem "zeus", "0.13.3" -gemspec :path => "../" +gemspec path: "../" diff --git a/gemfiles/rails_4_zeus_0.15.gemfile b/gemfiles/rails_4_zeus_0.15.gemfile index 7729cc2..0ecfc83 100644 --- a/gemfiles/rails_4_zeus_0.15.gemfile +++ b/gemfiles/rails_4_zeus_0.15.gemfile @@ -5,4 +5,4 @@ source "https://rubygems.org" gem "rails", "4.2.3" gem "zeus", "0.15.4" -gemspec :path => "../" +gemspec path: "../" diff --git a/spec/dummy/Guardfile b/spec/dummy/Guardfile index 629e478..2e68b71 100644 --- a/spec/dummy/Guardfile +++ b/spec/dummy/Guardfile @@ -3,21 +3,21 @@ guard 'rspec', zeus: true, parallel: true do watch(%r{^spec/.+_spec\.rb$}) - watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } - watch('spec/spec_helper.rb') { 'spec' } + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { 'spec' } # Rails example - watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } - watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } - watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } - watch(%r{^spec/support/(.+)\.rb$}) { 'spec' } - watch('config/routes.rb') { 'spec/routing' } - watch('app/controllers/application_controller.rb') { 'spec/controllers' } + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } + watch(%r{^spec/support/(.+)\.rb$}) { 'spec' } + watch('config/routes.rb') { 'spec/routing' } + watch('app/controllers/application_controller.rb') { 'spec/controllers' } # Capybara features specs - watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" } + watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/features/#{m[1]}_spec.rb" } # Turnip features and steps watch(%r{^spec/acceptance/(.+)\.feature$}) - watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } + watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' } end diff --git a/spec/dummy/config.ru b/spec/dummy/config.ru index 1989ed8..cbd7415 100644 --- a/spec/dummy/config.ru +++ b/spec/dummy/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path('../config/environment', __FILE__) run Dummy::Application diff --git a/spec/dummy/config/environments/test.rb b/spec/dummy/config/environments/test.rb index f7d264b..c87e031 100644 --- a/spec/dummy/config/environments/test.rb +++ b/spec/dummy/config/environments/test.rb @@ -15,14 +15,14 @@ config.whiny_nils = true # Show full error reports and disable caching - config.consider_all_requests_local = true + config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the diff --git a/spec/dummy/script/rails b/spec/dummy/script/rails index f8da2cf..bd79dce 100755 --- a/spec/dummy/script/rails +++ b/spec/dummy/script/rails @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. -APP_PATH = File.expand_path('../../config/application', __FILE__) -require File.expand_path('../../config/boot', __FILE__) +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'