lib/rspec/parallel/runner.rb in parallel-rspec-0.1.0 vs lib/rspec/parallel/runner.rb in parallel-rspec-0.1.1
- old
+ new
@@ -18,17 +18,19 @@
# worker processes to share its configuration.
configure_rspec
@master = Master.new(args)
end
- # @return [void]
+ # @return [Integer] exit status code
def start
+ waiters = []
RSpec::Parallel.configuration.concurrency.times do
- spawn_worker
+ waiters << spawn_worker
end
master.run
- Process.waitall
+ statuses = waiters.map {|waiter| waiter.value }
+ statuses.all? {|status| status.success? } ? 0 : 1
ensure
pids.each.with_index do |pid, index|
puts "----> output from worker[#{index}]"
File.open(output_file_path(pid)) do |file|
puts file.read
@@ -47,11 +49,11 @@
# @param master [RSpec::Parallel::Master]
def spawn_worker
pid = Kernel.fork do
master.close
- File.open(output_file_path($PID), "w") do |file|
+ exit_code = File.open(output_file_path($PID), "w") do |file|
# Redirect stdout and stderr to temp file
STDOUT.reopen(file)
STDERR.reopen(STDOUT)
STDOUT.sync = STDERR.sync = true
@@ -59,10 +61,10 @@
$0 = "parallel-rspec worker [#{worker.number}]"
RSpec::Parallel.configuration.after_fork_block.call(worker)
worker.run
end
- Kernel.exit! # avoid running any `at_exit` functions.
+ Kernel.exit!(exit_code == 0) # avoid running any `at_exit` functions.
end
pids << pid
Process.detach(pid)
end