aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_find.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 02:15:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-02 02:15:21 +0000
commitaad895181ee6852c39ac68ec9c98b74f33292eed (patch)
tree4e7a621f9ab53fbea361ee4f44e50e5d1d064960 /test/test_find.rb
parent2bb881148493651c577d95d55a4571c36de589b6 (diff)
downloadruby-aad895181ee6852c39ac68ec9c98b74f33292eed.tar.gz
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
Diffstat (limited to 'test/test_find.rb')
-rw-r--r--test/test_find.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/test_find.rb b/test/test_find.rb
index b9246510ed..8bd67829d3 100644
--- a/test/test_find.rb
+++ b/test/test_find.rb
@@ -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