ruby-changes:34167
From: nobu <ko1@a...>
Date: Fri, 30 May 2014 15:27:33 +0900 (JST)
Subject: [ruby-changes:34167] nobu:r46248 (trunk): minitest/unit.rb: defer requiring -test-
nobu 2014-05-30 15:27:23 +0900 (Fri, 30 May 2014) New Revision: 46248 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?revision=46248&view=revision Log: minitest/unit.rb: defer requiring -test- * test/lib/minitest/unit.rb (find_fds): defer requiring a library under "-test-" until needed, or can't work in other (installed) ruby. grep doesn't need separated map. Modified files: trunk/test/lib/minitest/unit.rb Index: test/lib/minitest/unit.rb =================================================================== --- test/lib/minitest/unit.rb (revision 46247) +++ test/lib/minitest/unit.rb (revision 46248) @@ -2,7 +2,6 @@ https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/unit.rb#L2 require "optparse" require "rbconfig" -require "-test-/dir" ## # Minimal (mostly drop-in) replacement for test-unit. @@ -991,19 +990,17 @@ module MiniTest https://github.com/ruby/ruby/blob/trunk/test/lib/minitest/unit.rb#L990 end def find_fds - fd_dir = "/proc/#{$$}/fd" + fd_dir = "/proc/self/fd" if File.directory?(fd_dir) + require "-test-/dir" fds = Dir.open(fd_dir) {|d| - a = [] - while fn = d.read - a << fn - end + a = d.grep(/\A\d+\z/, &:to_i) if d.respond_to? :fileno - a -= [d.fileno.to_s] + a -= [d.fileno] end a } - fds.grep(/\A\d+\z/).map(&:to_i).sort + fds.sort else [] end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/