From 1c35277c2bfecaf1128f05d8644b247fbd5ef461 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 27 May 2014 10:09:55 +0000 Subject: * io.c (rb_io_autoclose_p): Don't raise on frozen IO. * test/lib/minitest/unit.rb: IO#autoclose? may raise IOError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/lib/minitest/unit.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/lib/minitest') diff --git a/test/lib/minitest/unit.rb b/test/lib/minitest/unit.rb index 25160340db..5847da7d8c 100644 --- a/test/lib/minitest/unit.rb +++ b/test/lib/minitest/unit.rb @@ -1009,19 +1009,20 @@ module MiniTest h = {} ObjectSpace.each_object(IO) {|io| begin + autoclose = io.autoclose? fd = io.fileno rescue IOError # closed IO object next end - (h[fd] ||= []) << io + (h[fd] ||= []) << [io, autoclose] } fd_leaked.each {|fd| str = '' if h[fd] str << ' :' - h[fd].map {|io| + h[fd].map {|io, autoclose| s = ' ' + io.inspect - s << "(not-autoclose)" if !io.autoclose? + s << "(not-autoclose)" if !autoclose s }.each {|s| str << s @@ -1029,9 +1030,8 @@ module MiniTest end puts "Leaked file descriptor: #{name}: #{fd}#{str}" } - h.each {|fd, ios| - next if ios.length <= 1 - list = ios.map {|io| [io, io.autoclose?] } + h.each {|fd, list| + next if list.length <= 1 if 1 < list.count {|io, autoclose| autoclose } str = list.map {|io, autoclose| " #{io.inspect}" + (autoclose ? "(autoclose)" : "") }.sort.join puts "Multiple autoclose IO object for a file descriptor:#{str}" -- cgit v1.2.3