mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
test/unit.rb: extract launch_worker
* lib/test/unit.rb (Test::Unit::Runner#launch_worker): extract. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f098306036
commit
e9f68d7f69
2 changed files with 18 additions and 16 deletions
|
@ -1,4 +1,6 @@
|
|||
Sat Jul 14 16:16:17 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Sat Jul 14 16:16:22 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/test/unit.rb (Test::Unit::Runner#launch_worker): extract.
|
||||
|
||||
* lib/test/unit.rb (Test::Unit::Runner#start_watchdog): extract.
|
||||
|
||||
|
|
|
@ -452,6 +452,19 @@ module Test
|
|||
@ios = @workers.map(&:io)
|
||||
end
|
||||
|
||||
def launch_worker
|
||||
begin
|
||||
worker = Worker.launch(@options[:ruby],@args)
|
||||
rescue => e
|
||||
abort "ERROR: Failed to launch job process - #{e.class}: #{e.message}"
|
||||
end
|
||||
worker.hook(:dead) do |w,info|
|
||||
after_worker_quit w
|
||||
after_worker_down w, *info if !info.empty? && !worker.quit_called
|
||||
end
|
||||
worker
|
||||
end
|
||||
|
||||
def start_watchdog
|
||||
Thread.new do
|
||||
while stat = Process.wait2
|
||||
|
@ -487,20 +500,7 @@ module Test
|
|||
|
||||
begin
|
||||
# Array of workers.
|
||||
launch_worker = Proc.new {
|
||||
begin
|
||||
worker = Worker.launch(@options[:ruby],@args)
|
||||
rescue => e
|
||||
warn "ERROR: Failed to launch job process - #{e.class}: #{e.message}"
|
||||
exit 1
|
||||
end
|
||||
worker.hook(:dead) do |w,info|
|
||||
after_worker_quit w
|
||||
after_worker_down w, *info if !info.empty? && !worker.quit_called
|
||||
end
|
||||
worker
|
||||
}
|
||||
@workers = @options[:parallel].times.map(&launch_worker)
|
||||
@workers = @options[:parallel].times.map {launch_worker}
|
||||
|
||||
# Thread: watchdog
|
||||
watchdog = start_watchdog
|
||||
|
@ -527,7 +527,7 @@ module Test
|
|||
@workers_hash.delete worker.io
|
||||
@workers.delete worker
|
||||
@ios.delete worker.io
|
||||
new_worker = launch_worker.call()
|
||||
new_worker = launch_worker
|
||||
worker.quit
|
||||
@workers << new_worker
|
||||
@ios << new_worker.io
|
||||
|
|
Loading…
Add table
Reference in a new issue