1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

lib/test/unit/parallel.rb: new method to report to the parent

* lib/test/unit/parallel.rb (Test::Unit::Worker#_report): extract
  method to report to the parent process

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36137 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-06-19 09:22:01 +00:00
parent ab9560c953
commit bdfd26b795

View file

@ -35,7 +35,7 @@ module Test
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("m0")}" _report "p", buf
end end
rescue IOError rescue IOError
rescue Errno::EPIPE rescue Errno::EPIPE
@ -70,7 +70,7 @@ module Test
result << suite.name result << suite.name
begin begin
@stdout.puts "done #{[Marshal.dump(result)].pack("m0")}" _report "done", Marshal.dump(result)
rescue Errno::EPIPE; end rescue Errno::EPIPE; end
return result return result
ensure ensure
@ -98,14 +98,14 @@ module Test
exit 2 unless @stdout && @stdin exit 2 unless @stdout && @stdin
@stdout.sync = true @stdout.sync = true
@stdout.puts "ready!" _report "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" _report "okay"
@options = @opts.dup @options = @opts.dup
suites = MiniTest::Unit::TestCase.test_suites suites = MiniTest::Unit::TestCase.test_suites
@ -113,23 +113,23 @@ module Test
begin begin
require $1 require $1
rescue LoadError rescue LoadError
@stdout.puts "after #{[Marshal.dump([$1, $!])].pack("m0")}" _report "after", Marshal.dump([$1, $!])
@stdout.puts "ready" _report "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
if @need_exit if @need_exit
begin begin
@stdout.puts "bye" _report "bye"
rescue Errno::EPIPE; end rescue Errno::EPIPE; end
exit exit
else else
@stdout.puts "ready" _report "ready"
end end
when /^quit$/ when /^quit$/
begin begin
@stdout.puts "bye" _report "bye"
rescue Errno::EPIPE; end rescue Errno::EPIPE; end
exit exit
end end
@ -137,7 +137,7 @@ module Test
rescue Errno::EPIPE rescue Errno::EPIPE
rescue Exception => e rescue Exception => e
begin begin
@stdout.puts "bye #{[Marshal.dump(e)].pack("m0")}" if @stdout _report "bye", Marshal.dump(e)
rescue Errno::EPIPE;end rescue Errno::EPIPE;end
exit exit
ensure ensure
@ -146,6 +146,11 @@ module Test
end end
end end
def _report(res, *args)
res = "#{res} #{args.pack("m0")}" unless args.empty?
@stdout.puts(res)
end
def puke(klass, meth, e) def puke(klass, meth, e)
@partial_report << [klass.name, meth, e] @partial_report << [klass.name, meth, e]
super super