summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-14 07:16:19 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-07-14 07:16:19 +0000
commitf09830603644e2c09a696b5c468b810b099f1896 (patch)
tree713376b46742e77a504ff6e1853410e7bb363087 /lib
parentb789a6b4d676975ed2092b8ed7903b87b8798286 (diff)
test/unit.rb: extract start_watchdog
* lib/test/unit.rb (Test::Unit::Runner#start_watchdog): extract. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36383 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/test/unit.rb31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/test/unit.rb b/lib/test/unit.rb
index 6076eb8592..22e092a565 100644
--- a/lib/test/unit.rb
+++ b/lib/test/unit.rb
@@ -452,6 +452,22 @@ module Test
@ios = @workers.map(&:io)
end
+ def start_watchdog
+ Thread.new do
+ while stat = Process.wait2
+ break if @interrupt # Break when interrupt
+ pid, stat = stat
+ w = (@workers + @dead_workers).find{|x| pid == x.pid }
+ next unless w
+ w = w.dup
+ if w.status != :quit && !w.quit_called?
+ # Worker down
+ w.died(nil, !stat.signaled? && stat.exitstatus)
+ end
+ end
+ end
+ end
+
def _run_parallel suites, type, result
if @options[:parallel] < 1
warn "Error: parameter of -j option should be greater than 0."
@@ -487,20 +503,7 @@ module Test
@workers = @options[:parallel].times.map(&launch_worker)
# Thread: watchdog
- watchdog = Thread.new do
- while stat = Process.wait2
- break if @interrupt # Break when interrupt
- pid, stat = stat
- w = (@workers + @dead_workers).find{|x| pid == x.pid }
- next unless w
- w = w.dup
- if w.status != :quit && !w.quit_called?
- # Worker down
- w.died(nil, !stat.signaled? && stat.exitstatus)
- end
- end
- end
-
+ 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