test/unit.rb: launch_worker to manage new worker
* lib/test/unit.rb (Test::Unit::Runner#launch_worker): add new worker to working set. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e9f68d7f69
commit
4633ad5d0f
@ -1,4 +1,7 @@
|
|||||||
Sat Jul 14 16:16:22 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Jul 14 16:16:27 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/test/unit.rb (Test::Unit::Runner#launch_worker): add new worker
|
||||||
|
to working set.
|
||||||
|
|
||||||
* lib/test/unit.rb (Test::Unit::Runner#launch_worker): extract.
|
* lib/test/unit.rb (Test::Unit::Runner#launch_worker): extract.
|
||||||
|
|
||||||
|
@ -462,6 +462,9 @@ module Test
|
|||||||
after_worker_quit w
|
after_worker_quit w
|
||||||
after_worker_down w, *info if !info.empty? && !worker.quit_called
|
after_worker_down w, *info if !info.empty? && !worker.quit_called
|
||||||
end
|
end
|
||||||
|
@workers << worker
|
||||||
|
@ios << worker.io
|
||||||
|
@workers_hash[worker.io] = worker
|
||||||
worker
|
worker
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -498,14 +501,14 @@ module Test
|
|||||||
shutting_down = false
|
shutting_down = false
|
||||||
rep = [] # FIXME: more good naming
|
rep = [] # FIXME: more good naming
|
||||||
|
|
||||||
|
@workers = [] # Array of workers.
|
||||||
|
@workers_hash = {} # out-IO => worker
|
||||||
|
@ios = [] # Array of worker IOs
|
||||||
begin
|
begin
|
||||||
# Array of workers.
|
|
||||||
@workers = @options[:parallel].times.map {launch_worker}
|
|
||||||
|
|
||||||
# Thread: watchdog
|
# Thread: watchdog
|
||||||
watchdog = start_watchdog
|
watchdog = start_watchdog
|
||||||
@workers_hash = Hash[@workers.map {|w| [w.io,w] }] # out-IO => worker
|
|
||||||
@ios = @workers.map{|w| w.io } # Array of worker IOs
|
@options[:parallel].times {launch_worker}
|
||||||
|
|
||||||
while _io = IO.select(@ios)[0]
|
while _io = IO.select(@ios)[0]
|
||||||
break unless _io.each do |io|
|
break unless _io.each do |io|
|
||||||
@ -527,12 +530,8 @@ module Test
|
|||||||
@workers_hash.delete worker.io
|
@workers_hash.delete worker.io
|
||||||
@workers.delete worker
|
@workers.delete worker
|
||||||
@ios.delete worker.io
|
@ios.delete worker.io
|
||||||
new_worker = launch_worker
|
|
||||||
worker.quit
|
worker.quit
|
||||||
@workers << new_worker
|
worker = launch_worker
|
||||||
@ios << new_worker.io
|
|
||||||
@workers_hash[new_worker.io] = new_worker
|
|
||||||
worker = new_worker
|
|
||||||
end
|
end
|
||||||
worker.run(@tasks.shift, type)
|
worker.run(@tasks.shift, type)
|
||||||
@test_count += 1
|
@test_count += 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user