mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/test/unit.rb (_run_parallel):
New option "--separate" for test/unit; when running tests with this option, a job process will be restarted after one testcase has done. This means all testcases will run with separated process. * lib/test/unit/parallel.rb: Fix for above. Now parallel.rb puts "ready!" for first ready, "ready" for afters. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f8a4e2331b
commit
60da7a36f5
3 changed files with 45 additions and 8 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Sun Dec 25 22:39:49 2011 Shota Fukumori <sorah@tubusu.net>
|
||||
|
||||
* lib/test/unit.rb (_run_parallel):
|
||||
New option "--separate" for test/unit; when running tests with this
|
||||
option, a job process will be restarted after one testcase has done.
|
||||
This means all testcases will run with separated process.
|
||||
|
||||
* lib/test/unit/parallel.rb: Fix for above. Now parallel.rb puts
|
||||
"ready!" for first ready, "ready" for afters.
|
||||
|
||||
Sun Dec 25 00:02:15 2011 Luis Lavena <luislavena@gmail.com>
|
||||
|
||||
* configure.in: change --with-ntver to --with-winnt-ver to be more
|
||||
|
|
|
@ -96,6 +96,11 @@ module Test
|
|||
end
|
||||
end
|
||||
|
||||
opts.on '--separate', "Restart job process after one testcase has done" do
|
||||
options[:parallel] ||= 1
|
||||
options[:separate] = true
|
||||
end
|
||||
|
||||
opts.on '--no-retry', "Don't retry running testcase when --jobs specified" do
|
||||
options[:no_retry] = true
|
||||
end
|
||||
|
@ -243,6 +248,8 @@ module Test
|
|||
new(io, io.pid, :waiting)
|
||||
end
|
||||
|
||||
attr_reader :quit_called
|
||||
|
||||
def initialize(io, pid, status)
|
||||
@io = io
|
||||
@pid = pid
|
||||
|
@ -251,6 +258,7 @@ module Test
|
|||
@real_file = nil
|
||||
@loadpath = []
|
||||
@hooks = {}
|
||||
@quit_called = false
|
||||
end
|
||||
|
||||
def puts(*args)
|
||||
|
@ -289,6 +297,12 @@ module Test
|
|||
self
|
||||
end
|
||||
|
||||
def quit
|
||||
return if @io.closed?
|
||||
@quit_called = true
|
||||
@io.puts "quit"
|
||||
end
|
||||
|
||||
def died(*additional)
|
||||
@status = :quit
|
||||
@io.close
|
||||
|
@ -401,14 +415,15 @@ module Test
|
|||
rep = [] # FIXME: more good naming
|
||||
|
||||
# Array of workers.
|
||||
@workers = @options[:parallel].times.map {
|
||||
launch_worker = Proc.new {
|
||||
worker = Worker.launch(@options[:ruby],@args)
|
||||
worker.hook(:dead) do |w,info|
|
||||
after_worker_quit w
|
||||
after_worker_down w, *info unless info.empty?
|
||||
after_worker_down w, *info if !info.empty? && !worker.quit_called
|
||||
end
|
||||
worker
|
||||
}
|
||||
@workers = @options[:parallel].times.map(&launch_worker)
|
||||
|
||||
# Thread: watchdog
|
||||
watchdog = Thread.new do
|
||||
|
@ -417,7 +432,7 @@ module Test
|
|||
pid, stat = stat
|
||||
w = (@workers + @dead_workers).find{|x| pid == x.pid }.dup
|
||||
next unless w
|
||||
unless w.status == :quit
|
||||
if w.status != :quit && !w.quit_called?
|
||||
# Worker down
|
||||
w.died(nil, !stat.signaled? && stat.exitstatus)
|
||||
end
|
||||
|
@ -435,11 +450,23 @@ module Test
|
|||
when /^okay$/
|
||||
worker.status = :running
|
||||
jobs_status
|
||||
when /^ready$/
|
||||
when /^ready(!?)$/
|
||||
bang = $1
|
||||
worker.status = :ready
|
||||
if @tasks.empty?
|
||||
break unless @workers.find{|x| x.status == :running }
|
||||
else
|
||||
if @options[:separate] && bang.empty?
|
||||
@workers_hash.delete worker.io
|
||||
@workers.delete worker
|
||||
@ios.delete worker.io
|
||||
new_worker = launch_worker.call()
|
||||
worker.quit
|
||||
@workers << new_worker
|
||||
@ios << new_worker.io
|
||||
@workers_hash[new_worker.io] = new_worker
|
||||
worker = new_worker
|
||||
end
|
||||
worker.run(@tasks.shift, type)
|
||||
end
|
||||
|
||||
|
@ -459,7 +486,7 @@ module Test
|
|||
when /^bye (.+?)$/
|
||||
after_worker_down worker, Marshal.load($1.unpack("m")[0])
|
||||
when /^bye$/
|
||||
if shutting_down
|
||||
if shutting_down || worker.quit_called
|
||||
after_worker_quit worker
|
||||
else
|
||||
after_worker_down worker
|
||||
|
@ -496,7 +523,7 @@ module Test
|
|||
@workers.each do |worker|
|
||||
begin
|
||||
timeout(1) do
|
||||
worker.puts "quit"
|
||||
worker.quit
|
||||
end
|
||||
rescue Errno::EPIPE
|
||||
rescue Timeout::Error
|
||||
|
@ -529,7 +556,7 @@ module Test
|
|||
rep.each do |r|
|
||||
if r[:testcase] && r[:file] && !r[:report].empty?
|
||||
require r[:file]
|
||||
_run_suite(eval(r[:testcase]),type)
|
||||
_run_suite(eval("::"+r[:testcase]),type)
|
||||
else
|
||||
report.push(*r[:report])
|
||||
@errors += r[:result][0]
|
||||
|
|
|
@ -91,7 +91,7 @@ module Test
|
|||
@stdout = increment_io(STDOUT)
|
||||
@stdin = increment_io(STDIN)
|
||||
@stdout.sync = true
|
||||
@stdout.puts "ready"
|
||||
@stdout.puts "ready!"
|
||||
while buf = @stdin.gets
|
||||
case buf.chomp
|
||||
when /^loadpath (.+?)$/
|
||||
|
|
Loading…
Add table
Reference in a new issue