ruby-changes:24086
From: nobu <ko1@a...>
Date: Tue, 19 Jun 2012 18:22:11 +0900 (JST)
Subject: [ruby-changes:24086] nobu:r36137 (trunk): lib/test/unit/parallel.rb: new method to report to the parent
nobu 2012-06-19 18:22:01 +0900 (Tue, 19 Jun 2012) New Revision: 36137 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36137 Log: 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 Modified files: trunk/lib/test/unit/parallel.rb Index: lib/test/unit/parallel.rb =================================================================== --- lib/test/unit/parallel.rb (revision 36136) +++ lib/test/unit/parallel.rb (revision 36137) @@ -35,7 +35,7 @@ th = Thread.new do begin while buf = (self.verbose ? i.gets : i.read(5)) - @stdout.puts "p #{[buf].pack("m0")}" + _report "p", buf end rescue IOError rescue Errno::EPIPE @@ -70,7 +70,7 @@ result << suite.name begin - @stdout.puts "done #{[Marshal.dump(result)].pack("m0")}" + _report "done", Marshal.dump(result) rescue Errno::EPIPE; end return result ensure @@ -98,14 +98,14 @@ exit 2 unless @stdout && @stdin @stdout.sync = true - @stdout.puts "ready!" + _report "ready!" while buf = @stdin.gets case buf.chomp when /^loadpath (.+?)$/ @old_loadpath = $:.dup $:.push(*Marshal.load($1.unpack("m")[0].force_encoding("ASCII-8BIT"))).uniq! when /^run (.+?) (.+?)$/ - @stdout.puts "okay" + _report "okay" @options = @opts.dup suites = MiniTest::Unit::TestCase.test_suites @@ -113,23 +113,23 @@ begin require $1 rescue LoadError - @stdout.puts "after #{[Marshal.dump([$1, $!])].pack("m0")}" - @stdout.puts "ready" + _report "after", Marshal.dump([$1, $!]) + _report "ready" next end _run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym if @need_exit begin - @stdout.puts "bye" + _report "bye" rescue Errno::EPIPE; end exit else - @stdout.puts "ready" + _report "ready" end when /^quit$/ begin - @stdout.puts "bye" + _report "bye" rescue Errno::EPIPE; end exit end @@ -137,7 +137,7 @@ rescue Errno::EPIPE rescue Exception => e begin - @stdout.puts "bye #{[Marshal.dump(e)].pack("m0")}" if @stdout + _report "bye", Marshal.dump(e) rescue Errno::EPIPE;end exit ensure @@ -146,6 +146,11 @@ end end + def _report(res, *args) + res = "#{res} #{args.pack("m0")}" unless args.empty? + @stdout.puts(res) + end + def puke(klass, meth, e) @partial_report << [klass.name, meth, e] super -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/