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

ruby-changes:33184

From: ktsj <ko1@a...>
Date: Tue, 4 Mar 2014 00:29:03 +0900 (JST)
Subject: [ruby-changes:33184] ktsj:r45263 (trunk): * lib/find.rb (Find#find): should pass ignore_error option to enumerators.

ktsj	2014-03-04 00:28:58 +0900 (Tue, 04 Mar 2014)

  New Revision: 45263

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45263

  Log:
    * lib/find.rb (Find#find): should pass ignore_error option to enumerators.

  Modified files:
    trunk/ChangeLog
    trunk/lib/find.rb
    trunk/test/test_find.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45262)
+++ ChangeLog	(revision 45263)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Mar  4 00:25:35 2014  Kazuki Tsujimoto  <kazuki@c...>
+
+	* lib/find.rb (Find#find): should pass ignore_error option to enumerators.
+
 Mon Mar  3 13:27:35 2014  NAKAMURA Usaku  <usa@r...>
 
 	* test/test_find.rb (TestFind#test_unsearchable_dir): ruby cannot make
Index: lib/find.rb
===================================================================
--- lib/find.rb	(revision 45262)
+++ lib/find.rb	(revision 45263)
@@ -35,7 +35,7 @@ module Find https://github.com/ruby/ruby/blob/trunk/lib/find.rb#L35
   # See the +Find+ module documentation for an example.
   #
   def find(*paths, ignore_error: true) # :yield: path
-    block_given? or return enum_for(__method__, *paths)
+    block_given? or return enum_for(__method__, *paths, ignore_error: ignore_error)
 
     fs_encoding = Encoding.find("filesystem")
 
Index: test/test_find.rb
===================================================================
--- test/test_find.rb	(revision 45262)
+++ test/test_find.rb	(revision 45263)
@@ -106,10 +106,20 @@ class TestFind < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_find.rb#L106
         assert_equal([d, dir], a)
 
         a = []
+        Find.find(d, ignore_error: true).each {|f| a << f }
+        assert_equal([d, dir], a)
+
+        a = []
         assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(dir)}/) do
           Find.find(d, ignore_error: false) {|f| a << f }
         end
         assert_equal([d, dir], a)
+
+        a = []
+        assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(dir)}/) do
+          Find.find(d, ignore_error: false).each {|f| a << f }
+        end
+        assert_equal([d, dir], a)
       ensure
         File.chmod(0700, dir)
       end
@@ -130,6 +140,10 @@ class TestFind < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_find.rb#L140
         Find.find(d, ignore_error: true) {|f| a << f }
         assert_equal([d, dir, file], a)
 
+        a = []
+        Find.find(d, ignore_error: true).each {|f| a << f }
+        assert_equal([d, dir, file], a)
+
         skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
         a = []
         assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(file)}/) do
@@ -137,6 +151,12 @@ class TestFind < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_find.rb#L151
         end
         assert_equal([d, dir, file], a)
 
+        a = []
+        assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(file)}/) do
+          Find.find(d, ignore_error: false).each {|f| a << f }
+        end
+        assert_equal([d, dir, file], a)
+
         assert_raise(Errno::EACCES) { File.lstat(file) }
       ensure
         File.chmod(0700, dir)

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

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