method
_run_parallel
v2_1_10 -
Show latest stable
- Class:
Test::Unit::Runner
_run_parallel(suites, type, result)public
No documentation available.
# File lib/test/unit.rb, line 570
def _run_parallel suites, type, result
if @options[:parallel] < 1
warn "Error: parameter of -j option should be greater than 0."
return
end
# Require needed things for parallel running
require 'thread'
require 'timeout'
@tasks = @files.dup # Array of filenames.
@need_quit = false
@dead_workers = [] # Array of dead workers.
@warnings = []
@total_tests = @tasks.size.to_s(10)
rep = [] # FIXME: more good naming
@workers = [] # Array of workers.
@workers_hash = {} # out-IO => worker
@ios = [] # Array of worker IOs
begin
# Thread: watchdog
watchdog = start_watchdog
@options[:parallel].times {launch_worker}
while _io = IO.select(@ios)[0]
break if _io.any? do |io|
@need_quit or
(deal(io, type, result, rep).nil? and
[email protected]? {|x| [:running, :prepare].include? x.status})
end
end
rescue Interrupt => ex
@interrupt = ex
return result
ensure
watchdog.kill if watchdog
if @interrupt
@ios.select!{|x| @workers_hash[x].status == :running }
while [email protected]? && (__io = IO.select(@ios,[],[],10))
__io[0].reject! {|io| deal(io, type, result, rep, true)}
end
end
quit_workers
unless @interrupt || !@options[:retry] || @need_quit
@options[:parallel] = false
suites, rep = rep.partition {|r| r[:testcase] && r[:file] && r[:report].any? {|e| !e[2].is_a?(MiniTest::Skip)}}
suites.map {|r| r[:file]}.uniq.each {|file| require file}
suites.map! {|r| eval("::"+r[:testcase])}
del_status_line or puts
unless suites.empty?
puts "Retrying..."
_run_suites(suites, type)
end
end
unless @options[:retry]
del_status_line or puts
end
unless rep.empty?
rep.each do |r|
r[:report].each do |f|
puke(*f) if f
end
end
if @options[:retry]
@errors += rep.map{|x| x[:result][0] }.inject(:+)
@failures += rep.map{|x| x[:result][1] }.inject(:+)
@skips += rep.map{|x| x[:result][2] }.inject(:+)
end
end
unless @warnings.empty?
warn ""
@warnings.uniq! {|w| w[1].message}
@warnings.each do |w|
warn "#{w[0]}: #{w[1].message} (#{w[1].class})"
end
warn ""
end
end
end