ruby-changes:22919
From: sorah <ko1@a...>
Date: Sun, 11 Mar 2012 17:29:40 +0900 (JST)
Subject: [ruby-changes:22919] sorah:r34968 (trunk): * lib/test/unit.rb: Put error message into STDERR if failed to lanch
sorah 2012-03-11 17:28:48 +0900 (Sun, 11 Mar 2012) New Revision: 34968 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34968 Log: * lib/test/unit.rb: Put error message into STDERR if failed to lanch worker (job) process. [ruby-dev:44802] [Bug #5577] * lib/test/unit/parallel.rb: If failed to increment_io, exit with code 2. [ruby-dev:44802] [Bug #5577] Modified files: trunk/ChangeLog trunk/lib/test/unit/parallel.rb trunk/lib/test/unit.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34967) +++ ChangeLog (revision 34968) @@ -1,3 +1,11 @@ +Sun Mar 11 17:10:04 2012 Shota Fukumori <sorah@t...> + + * lib/test/unit.rb: Put error message into STDERR if failed to lanch + worker (job) process. [ruby-dev:44802] [Bug #5577] + + * lib/test/unit/parallel.rb: If failed to increment_io, exit with code + 2. [ruby-dev:44802] [Bug #5577] + Sun Mar 11 15:46:45 2012 Shota Fukumori <sorah@t...> * io.c: fix rdoc of `IO.binwrite` to show same as `IO.write` except Index: lib/test/unit/parallel.rb =================================================================== --- lib/test/unit/parallel.rb (revision 34967) +++ lib/test/unit/parallel.rb (revision 34968) @@ -88,8 +88,14 @@ @old_loadpath = [] begin - @stdout = increment_io(STDOUT) - @stdin = increment_io(STDIN) + begin + @stdout = increment_io(STDOUT) + @stdin = increment_io(STDIN) + rescue + exit 2 + end + exit 2 unless @stdout && @stdin + @stdout.sync = true @stdout.puts "ready!" while buf = @stdin.gets @@ -130,12 +136,12 @@ rescue Errno::EPIPE rescue Exception => e begin - @stdout.puts "bye #{[Marshal.dump(e)].pack("m0")}" + @stdout.puts "bye #{[Marshal.dump(e)].pack("m0")}" if @stdout rescue Errno::EPIPE;end exit ensure - @stdin.close - @stdout.close + @stdin.close if @stdin + @stdout.close if @stdout end end end Index: lib/test/unit.rb =================================================================== --- lib/test/unit.rb (revision 34967) +++ lib/test/unit.rb (revision 34968) @@ -429,7 +429,12 @@ # Array of workers. launch_worker = Proc.new { - worker = Worker.launch(@options[:ruby],@args) + begin + worker = Worker.launch(@options[:ruby],@args) + rescue => e + warn "ERROR: Failed to launch job process - #{e.class}: #{e.message}" + exit 1 + end worker.hook(:dead) do |w,info| after_worker_quit w after_worker_down w, *info if !info.empty? && !worker.quit_called @@ -536,27 +541,31 @@ end end end - @workers.each do |worker| + + if @workers + @workers.each do |worker| + begin + timeout(1) do + worker.quit + end + rescue Errno::EPIPE + rescue Timeout::Error + end + worker.close + end + begin - timeout(1) do - worker.quit + timeout(0.2*@workers.size) do + Process.waitall end - rescue Errno::EPIPE rescue Timeout::Error + @workers.each do |worker| + begin + Process.kill(:KILL,worker.pid) + rescue Errno::ESRCH; end + end end - worker.close end - begin - timeout(0.2*@workers.size) do - Process.waitall - end - rescue Timeout::Error - @workers.each do |worker| - begin - Process.kill(:KILL,worker.pid) - rescue Errno::ESRCH; end - end - end if @interrupt || !@options[:retry] || @need_quit rep.each do |r| @@ -565,7 +574,7 @@ @errors += rep.map{|x| x[:result][0] }.inject(:+) @failures += rep.map{|x| x[:result][1] }.inject(:+) @skips += rep.map{|x| x[:result][2] }.inject(:+) - else + elsif @workers puts "" puts "Retrying..." puts "" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/