[前][次][番号順一覧][スレッド一覧]

ruby-changes:60806

From: Nobuyoshi <ko1@a...>
Date: Fri, 17 Apr 2020 14:34:37 +0900 (JST)
Subject: [ruby-changes:60806] 3152977b31 (master): Rescue EPIPE in _report

https://git.ruby-lang.org/ruby.git/commit/?id=3152977b31

From 3152977b31b64dde776724188bdaa927b07d524d Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 15 Apr 2020 01:29:13 +0900
Subject: Rescue EPIPE in _report

Instead of letting callers rescue the error always.

diff --git a/tool/lib/test/unit/parallel.rb b/tool/lib/test/unit/parallel.rb
index 15f9ac5..afb0d01 100644
--- a/tool/lib/test/unit/parallel.rb
+++ b/tool/lib/test/unit/parallel.rb
@@ -43,10 +43,9 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/parallel.rb#L43
         th = Thread.new do
           begin
             while buf = (self.verbose ? i.gets : i.readpartial(1024))
-              _report "p", buf
+              _report "p", buf or break
             end
           rescue IOError
-          rescue Errno::EPIPE
           end
         end
 
@@ -77,9 +76,7 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/parallel.rb#L76
         result << ($: - @old_loadpath)
         result << suite.name
 
-        begin
-          _report "done", Marshal.dump(result)
-        rescue Errno::EPIPE; end
+        _report "done", Marshal.dump(result)
         return result
       ensure
         MiniTest::Unit.output = orig_stdout
@@ -128,32 +125,25 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/parallel.rb#L125
               _run_suites MiniTest::Unit::TestCase.test_suites-suites, $2.to_sym
 
               if @need_exit
-                begin
-                  _report "bye"
-                rescue Errno::EPIPE; end
+                _report "bye"
                 exit
               else
                 _report "ready"
               end
             when /^quit$/
-              begin
-                _report "bye"
-              rescue Errno::EPIPE; end
+              _report "bye"
               exit
             end
           end
-        rescue Errno::EPIPE
         rescue Exception => e
-          begin
-            trace = e.backtrace || ['unknown method']
-            err = ["#{trace.shift}: #{e.message} (#{e.class})"] + trace.map{|t| "\t" + t }
+          trace = e.backtrace || ['unknown method']
+          err = ["#{trace.shift}: #{e.message} (#{e.class})"] + trace.map{|t| "\t" + t }
 
-            if @stdout
-              _report "bye", Marshal.dump(err.join("\n"))
-            else
-              raise "failed to report a failure due to lack of @stdout"
-            end
-          rescue Errno::EPIPE;end
+          if @stdout
+            _report "bye", Marshal.dump(err.join("\n"))
+          else
+            raise "failed to report a failure due to lack of @stdout"
+          end
           exit
         ensure
           @stdin.close if @stdin
@@ -163,6 +153,8 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit/parallel.rb#L153
 
       def _report(res, *args) # :nodoc:
         @stdout.write(args.empty? ? "#{res}\n" : "#{res} #{args.pack("m0")}\n")
+        true
+      rescue Errno::EPIPE
       rescue TypeError => e
         abort("#{e.inspect} in _report(#{res.inspect}, #{args.inspect})\n#{e.backtrace.join("\n")}")
       end
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]