mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
b789a6b4d6
commit
f098306036
2 changed files with 20 additions and 15 deletions
|
@ -1,4 +1,6 @@
|
||||||
Sat Jul 14 16:16:12 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Jul 14 16:16:17 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/test/unit.rb (Test::Unit::Runner#start_watchdog): extract.
|
||||||
|
|
||||||
* lib/test/unit.rb (Test::Unit::Runner#_run_parallel): move
|
* lib/test/unit.rb (Test::Unit::Runner#_run_parallel): move
|
||||||
initializations with nothing to release outside begin/ensure.
|
initializations with nothing to release outside begin/ensure.
|
||||||
|
|
|
@ -452,6 +452,22 @@ module Test
|
||||||
@ios = @workers.map(&:io)
|
@ios = @workers.map(&:io)
|
||||||
end
|
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
|
def _run_parallel suites, type, result
|
||||||
if @options[:parallel] < 1
|
if @options[:parallel] < 1
|
||||||
warn "Error: parameter of -j option should be greater than 0."
|
warn "Error: parameter of -j option should be greater than 0."
|
||||||
|
@ -487,20 +503,7 @@ module Test
|
||||||
@workers = @options[:parallel].times.map(&launch_worker)
|
@workers = @options[:parallel].times.map(&launch_worker)
|
||||||
|
|
||||||
# Thread: watchdog
|
# Thread: watchdog
|
||||||
watchdog = Thread.new do
|
watchdog = start_watchdog
|
||||||
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
|
|
||||||
|
|
||||||
@workers_hash = Hash[@workers.map {|w| [w.io,w] }] # out-IO => worker
|
@workers_hash = Hash[@workers.map {|w| [w.io,w] }] # out-IO => worker
|
||||||
@ios = @workers.map{|w| w.io } # Array of worker IOs
|
@ios = @workers.map{|w| w.io } # Array of worker IOs
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue