зеркало из https://github.com/github/ruby.git
* lib/test/unit/parallel.rb: For Windows.
* test/testunit/test_parallel.rb(TestParallelWorker#test_quit_in_test): Fix for above specification change. * test/testunit/test_parallel.rb(TestParallel#spawn_runner): Fix outputing empty line in running test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
af3e36158f
Коммит
0a9442983d
|
@ -1,3 +1,12 @@
|
||||||
|
Tue Mar 1 21:48:22 2011 Shota Fukumori <sorah@tubusu.net>
|
||||||
|
|
||||||
|
* lib/test/unit/parallel.rb: For Windows.
|
||||||
|
|
||||||
|
* test/testunit/test_parallel.rb(TestParallelWorker#test_quit_in_test):
|
||||||
|
Fix for above specification change.
|
||||||
|
* test/testunit/test_parallel.rb(TestParallel#spawn_runner):
|
||||||
|
Fix outputing empty line in running test.
|
||||||
|
|
||||||
Tue Mar 1 20:51:57 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
Tue Mar 1 20:51:57 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* test/ruby/test_system.rb (TestSystem#test_system_at):
|
* test/ruby/test_system.rb (TestSystem#test_system_at):
|
||||||
|
|
|
@ -12,6 +12,12 @@ module Test
|
||||||
undef _run_suites
|
undef _run_suites
|
||||||
undef run
|
undef run
|
||||||
|
|
||||||
|
def inclement_io orig
|
||||||
|
*rest, io = 500.times.inject([orig.dup]){|ios, | ios << ios.last.dup }
|
||||||
|
rest.each(&:close)
|
||||||
|
io
|
||||||
|
end
|
||||||
|
|
||||||
def _run_suites suites, type
|
def _run_suites suites, type
|
||||||
suites.map do |suite|
|
suites.map do |suite|
|
||||||
result = _run_suite(suite, type)
|
result = _run_suite(suite, type)
|
||||||
|
@ -24,12 +30,10 @@ module Test
|
||||||
i,o = IO.pipe
|
i,o = IO.pipe
|
||||||
MiniTest::Unit.output = o
|
MiniTest::Unit.output = o
|
||||||
|
|
||||||
stdout = STDOUT.dup
|
|
||||||
|
|
||||||
th = Thread.new do
|
th = Thread.new do
|
||||||
begin
|
begin
|
||||||
while buf = (self.verbose ? i.gets : i.read(5))
|
while buf = (self.verbose ? i.gets : i.read(5))
|
||||||
stdout.puts "p #{[buf].pack("m").gsub("\n","")}"
|
@stdout.puts "p #{[buf].pack("m").gsub("\n","")}"
|
||||||
end
|
end
|
||||||
rescue IOError
|
rescue IOError
|
||||||
rescue Errno::EPIPE
|
rescue Errno::EPIPE
|
||||||
|
@ -56,7 +60,7 @@ module Test
|
||||||
result << suite.name
|
result << suite.name
|
||||||
|
|
||||||
begin
|
begin
|
||||||
STDOUT.puts "done #{[Marshal.dump(result)].pack("m").gsub("\n","")}"
|
@stdout.puts "done #{[Marshal.dump(result)].pack("m").gsub("\n","")}"
|
||||||
rescue Errno::EPIPE; end
|
rescue Errno::EPIPE; end
|
||||||
return result
|
return result
|
||||||
ensure
|
ensure
|
||||||
|
@ -73,28 +77,17 @@ module Test
|
||||||
Signal.trap(:INT,"IGNORE")
|
Signal.trap(:INT,"IGNORE")
|
||||||
@old_loadpath = []
|
@old_loadpath = []
|
||||||
begin
|
begin
|
||||||
STDOUT.sync = true
|
@stdout = inclement_io(STDOUT)
|
||||||
STDOUT.puts "ready"
|
@stdin = inclement_io(STDIN)
|
||||||
stdin = STDIN.dup
|
@stdout.sync = true
|
||||||
stdout = STDOUT.dup
|
@stdout.puts "ready"
|
||||||
while buf = stdin.gets
|
while buf = @stdin.gets
|
||||||
case buf.chomp
|
case buf.chomp
|
||||||
when /^loadpath (.+?)$/
|
when /^loadpath (.+?)$/
|
||||||
@old_loadpath = $:.dup
|
@old_loadpath = $:.dup
|
||||||
$:.push(*Marshal.load($1.unpack("m")[0].force_encoding("ASCII-8BIT"))).uniq!
|
$:.push(*Marshal.load($1.unpack("m")[0].force_encoding("ASCII-8BIT"))).uniq!
|
||||||
when /^run (.+?) (.+?)$/
|
when /^run (.+?) (.+?)$/
|
||||||
STDOUT.puts "okay"
|
@stdout.puts "okay"
|
||||||
|
|
||||||
th = Thread.new do
|
|
||||||
while puf = stdin.gets
|
|
||||||
if puf.chomp == "quit"
|
|
||||||
begin
|
|
||||||
stdout.puts "bye"
|
|
||||||
rescue Errno::EPIPE; end
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
@options = @opts.dup
|
@options = @opts.dup
|
||||||
suites = MiniTest::Unit::TestCase.test_suites
|
suites = MiniTest::Unit::TestCase.test_suites
|
||||||
|
@ -102,21 +95,16 @@ module Test
|
||||||
begin
|
begin
|
||||||
require $1
|
require $1
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
th.kill
|
@stdout.puts "after #{[Marshal.dump([$1, $!])].pack("m").gsub("\n","")}"
|
||||||
STDOUT.puts "after #{[Marshal.dump([$1, $!])].pack("m").gsub("\n","")}"
|
@stdout.puts "ready"
|
||||||
STDOUT.puts "ready"
|
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
_run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym
|
_run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym
|
||||||
|
|
||||||
STDIN.reopen(stdin)
|
@stdout.puts "ready"
|
||||||
STDOUT.reopen(stdout)
|
|
||||||
|
|
||||||
th.kill
|
|
||||||
STDOUT.puts "ready"
|
|
||||||
when /^quit$/
|
when /^quit$/
|
||||||
begin
|
begin
|
||||||
STDOUT.puts "bye"
|
@stdout.puts "bye"
|
||||||
rescue Errno::EPIPE; end
|
rescue Errno::EPIPE; end
|
||||||
exit
|
exit
|
||||||
end
|
end
|
||||||
|
@ -124,11 +112,12 @@ module Test
|
||||||
rescue Errno::EPIPE
|
rescue Errno::EPIPE
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
begin
|
begin
|
||||||
STDOUT.puts "bye #{[Marshal.dump(e)].pack("m").gsub("\n","")}"
|
@stdout.puts "bye #{[Marshal.dump(e)].pack("m").gsub("\n","")}"
|
||||||
rescue Errno::EPIPE;end
|
rescue Errno::EPIPE;end
|
||||||
exit
|
exit
|
||||||
ensure
|
ensure
|
||||||
stdin.close
|
@stdin.close
|
||||||
|
@stdout.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -117,14 +117,6 @@ module TestParallel
|
||||||
assert_match(/^bye$/m,@worker_out.read)
|
assert_match(/^bye$/m,@worker_out.read)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_quit_in_test
|
|
||||||
timeout(10) do
|
|
||||||
@worker_in.puts "run #{TESTS}/test_third.rb ptest"
|
|
||||||
@worker_in.puts "quit"
|
|
||||||
assert_match(/^ready\nokay\nbye/m,@worker_out.read)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class TestParallel < Test::Unit::TestCase
|
class TestParallel < Test::Unit::TestCase
|
||||||
|
@ -137,7 +129,7 @@ module TestParallel
|
||||||
def spawn_runner(*opt_args)
|
def spawn_runner(*opt_args)
|
||||||
@test_out, o = IO.pipe
|
@test_out, o = IO.pipe
|
||||||
@test_pid = spawn(*@options[:ruby], TESTS+"/runner.rb",
|
@test_pid = spawn(*@options[:ruby], TESTS+"/runner.rb",
|
||||||
"-j","t2","-x","sleeping",*opt_args, out: o)
|
"-j","t2","-x","sleeping",*opt_args, out: o, err: :out)
|
||||||
o.close
|
o.close
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче