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

find.rb: add ignore_error

* lib/find.rb (Find#find): add "ignore_error" keyword argument
  defaulted to true.  [ruby-core:51025] [Feature #7596]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-03-02 02:15:21 +00:00
parent 2bb8811484
commit aad895181e
3 changed files with 29 additions and 1 deletions

View file

@ -100,6 +100,16 @@ class TestFind < Test::Unit::TestCase
a = []
Find.find(d) {|f| a << f }
assert_equal([d, dir], a)
a = []
Find.find(d, ignore_error: true) {|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)
ensure
File.chmod(0700, dir)
end
@ -115,6 +125,17 @@ class TestFind < Test::Unit::TestCase
a = []
Find.find(d) {|f| a << f }
assert_equal([d, dir, file], a)
a = []
Find.find(d, ignore_error: true) {|f| a << f }
assert_equal([d, dir, file], a)
a = []
assert_raise_with_message(Errno::EACCES, /#{Regexp.quote(file)}/) do
Find.find(d, ignore_error: false) {|f| a << f }
end
assert_equal([d, dir, file], a)
skip "no meaning test on Windows" if /mswin|mingw/ =~ RUBY_PLATFORM
assert_raise(Errno::EACCES) { File.lstat(file) }
ensure