Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Return the correct exit code #45

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion gemfiles/rails_3_zeus_0.13.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "rails", "3.2.21"
gem "zeus", "0.13.3"

gemspec :path => "../"
gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_3_zeus_0.15.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "rails", "3.2.21"
gem "zeus", "0.15.4"

gemspec :path => "../"
gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4_zeus_0.13.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "rails", "4.2.3"
gem "zeus", "0.13.3"

gemspec :path => "../"
gemspec path: "../"
2 changes: 1 addition & 1 deletion gemfiles/rails_4_zeus_0.15.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ source "https://rubygems.org"
gem "rails", "4.2.3"
gem "zeus", "0.15.4"

gemspec :path => "../"
gemspec path: "../"
3 changes: 2 additions & 1 deletion lib/zeus/parallel_tests/worker.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require_relative '../parallel_tests'
require 'tempfile'
require 'English'

module Zeus
module ParallelTests
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions spec/dummy/Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion spec/dummy/config.ru
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions spec/dummy/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/dummy/script/rails
Original file line number Diff line number Diff line change
@@ -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'
14 changes: 10 additions & 4 deletions spec/lib/zeus/parallel_tests/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
6 changes: 4 additions & 2 deletions zeus-parallel_tests.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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