method
_run_parallel
Ruby latest stable (v2_5_5)
-
0 notes -
Class: Runner
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9
- 2_4_6
- 2_5_5
- 2_6_3
- What's this?
_run_parallel(suites, type, result)
public
Hide source
# 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 !@workers.any? {|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 !@ios.empty? && (__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