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

Rescue EPIPE in _report

Instead of letting callers rescue the error always.
This commit is contained in:
Nobuyoshi Nakada 2020-04-15 01:29:13 +09:00
parent b5132d91c0
commit 3152977b31
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -43,10 +43,9 @@ module Test
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
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
_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
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