* 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
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>
|
Sun Dec 25 00:02:15 2011 Luis Lavena <luislavena@gmail.com>
|
||||||
|
|
||||||
* configure.in: change --with-ntver to --with-winnt-ver to be more
|
* configure.in: change --with-ntver to --with-winnt-ver to be more
|
||||||
|
@ -96,6 +96,11 @@ module Test
|
|||||||
end
|
end
|
||||||
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
|
opts.on '--no-retry', "Don't retry running testcase when --jobs specified" do
|
||||||
options[:no_retry] = true
|
options[:no_retry] = true
|
||||||
end
|
end
|
||||||
@ -243,6 +248,8 @@ module Test
|
|||||||
new(io, io.pid, :waiting)
|
new(io, io.pid, :waiting)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attr_reader :quit_called
|
||||||
|
|
||||||
def initialize(io, pid, status)
|
def initialize(io, pid, status)
|
||||||
@io = io
|
@io = io
|
||||||
@pid = pid
|
@pid = pid
|
||||||
@ -251,6 +258,7 @@ module Test
|
|||||||
@real_file = nil
|
@real_file = nil
|
||||||
@loadpath = []
|
@loadpath = []
|
||||||
@hooks = {}
|
@hooks = {}
|
||||||
|
@quit_called = false
|
||||||
end
|
end
|
||||||
|
|
||||||
def puts(*args)
|
def puts(*args)
|
||||||
@ -289,6 +297,12 @@ module Test
|
|||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def quit
|
||||||
|
return if @io.closed?
|
||||||
|
@quit_called = true
|
||||||
|
@io.puts "quit"
|
||||||
|
end
|
||||||
|
|
||||||
def died(*additional)
|
def died(*additional)
|
||||||
@status = :quit
|
@status = :quit
|
||||||
@io.close
|
@io.close
|
||||||
@ -401,14 +415,15 @@ module Test
|
|||||||
rep = [] # FIXME: more good naming
|
rep = [] # FIXME: more good naming
|
||||||
|
|
||||||
# Array of workers.
|
# Array of workers.
|
||||||
@workers = @options[:parallel].times.map {
|
launch_worker = Proc.new {
|
||||||
worker = Worker.launch(@options[:ruby],@args)
|
worker = Worker.launch(@options[:ruby],@args)
|
||||||
worker.hook(:dead) do |w,info|
|
worker.hook(:dead) do |w,info|
|
||||||
after_worker_quit w
|
after_worker_quit w
|
||||||
after_worker_down w, *info unless info.empty?
|
after_worker_down w, *info if !info.empty? && !worker.quit_called
|
||||||
end
|
end
|
||||||
worker
|
worker
|
||||||
}
|
}
|
||||||
|
@workers = @options[:parallel].times.map(&launch_worker)
|
||||||
|
|
||||||
# Thread: watchdog
|
# Thread: watchdog
|
||||||
watchdog = Thread.new do
|
watchdog = Thread.new do
|
||||||
@ -417,7 +432,7 @@ module Test
|
|||||||
pid, stat = stat
|
pid, stat = stat
|
||||||
w = (@workers + @dead_workers).find{|x| pid == x.pid }.dup
|
w = (@workers + @dead_workers).find{|x| pid == x.pid }.dup
|
||||||
next unless w
|
next unless w
|
||||||
unless w.status == :quit
|
if w.status != :quit && !w.quit_called?
|
||||||
# Worker down
|
# Worker down
|
||||||
w.died(nil, !stat.signaled? && stat.exitstatus)
|
w.died(nil, !stat.signaled? && stat.exitstatus)
|
||||||
end
|
end
|
||||||
@ -435,11 +450,23 @@ module Test
|
|||||||
when /^okay$/
|
when /^okay$/
|
||||||
worker.status = :running
|
worker.status = :running
|
||||||
jobs_status
|
jobs_status
|
||||||
when /^ready$/
|
when /^ready(!?)$/
|
||||||
|
bang = $1
|
||||||
worker.status = :ready
|
worker.status = :ready
|
||||||
if @tasks.empty?
|
if @tasks.empty?
|
||||||
break unless @workers.find{|x| x.status == :running }
|
break unless @workers.find{|x| x.status == :running }
|
||||||
else
|
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)
|
worker.run(@tasks.shift, type)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -459,7 +486,7 @@ module Test
|
|||||||
when /^bye (.+?)$/
|
when /^bye (.+?)$/
|
||||||
after_worker_down worker, Marshal.load($1.unpack("m")[0])
|
after_worker_down worker, Marshal.load($1.unpack("m")[0])
|
||||||
when /^bye$/
|
when /^bye$/
|
||||||
if shutting_down
|
if shutting_down || worker.quit_called
|
||||||
after_worker_quit worker
|
after_worker_quit worker
|
||||||
else
|
else
|
||||||
after_worker_down worker
|
after_worker_down worker
|
||||||
@ -496,7 +523,7 @@ module Test
|
|||||||
@workers.each do |worker|
|
@workers.each do |worker|
|
||||||
begin
|
begin
|
||||||
timeout(1) do
|
timeout(1) do
|
||||||
worker.puts "quit"
|
worker.quit
|
||||||
end
|
end
|
||||||
rescue Errno::EPIPE
|
rescue Errno::EPIPE
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
@ -529,7 +556,7 @@ module Test
|
|||||||
rep.each do |r|
|
rep.each do |r|
|
||||||
if r[:testcase] && r[:file] && !r[:report].empty?
|
if r[:testcase] && r[:file] && !r[:report].empty?
|
||||||
require r[:file]
|
require r[:file]
|
||||||
_run_suite(eval(r[:testcase]),type)
|
_run_suite(eval("::"+r[:testcase]),type)
|
||||||
else
|
else
|
||||||
report.push(*r[:report])
|
report.push(*r[:report])
|
||||||
@errors += r[:result][0]
|
@errors += r[:result][0]
|
||||||
|
@ -91,7 +91,7 @@ module Test
|
|||||||
@stdout = increment_io(STDOUT)
|
@stdout = increment_io(STDOUT)
|
||||||
@stdin = increment_io(STDIN)
|
@stdin = increment_io(STDIN)
|
||||||
@stdout.sync = true
|
@stdout.sync = true
|
||||||
@stdout.puts "ready"
|
@stdout.puts "ready!"
|
||||||
while buf = @stdin.gets
|
while buf = @stdin.gets
|
||||||
case buf.chomp
|
case buf.chomp
|
||||||
when /^loadpath (.+?)$/
|
when /^loadpath (.+?)$/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user