From c754b227978af124734fb90be703c923b0752519 Mon Sep 17 00:00:00 2001 From: ktsj Date: Mon, 3 Mar 2014 15:28:58 +0000 Subject: * lib/find.rb (Find#find): should pass ignore_error option to enumerators. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_find.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/test_find.rb') diff --git a/test/test_find.rb b/test/test_find.rb index af0cb2dc95..cb2ce56129 100644 --- a/test/test_find.rb +++ b/test/test_find.rb @@ -105,11 +105,21 @@ class TestFind < Test::Unit::TestCase Find.find(d, ignore_error: true) {|f| a << f } 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 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 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) -- cgit v1.2.3