summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-14 07:16:24 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-14 07:16:24 +0000
commite9f68d7f69704558af0e0721f53c53687d5b187e (patch)
tree2426409fab252941bc813db80e5ce525349aebcf /lib
parentf09830603644e2c09a696b5c468b810b099f1896 (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/test/unit.rb30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index 22e092a565..91abec71f0 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -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