summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-12 18:17:02 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-12 20:02:43 +0900
commit7dc0511ea4be210f82abb1c82a31aec3a4fe5736 (patch)
tree641de37d2e24fe9c7ba3d30536a7c9b0886537e5 /test
parentccabf4966f4c5a7e19fec52b690d07bf471fc5d1 (diff)
Remove "." and ".." from Dir.glob with FNM_DOTMATCH [Bug #17280]
Co-authored-by: Jeremy Evans <code@jeremyevans.net>
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4052
Diffstat (limited to 'test')
-rw-r--r--test/pathname/test_pathname.rb2
-rw-r--r--test/ruby/test_dir.rb5
2 files changed, 5 insertions, 2 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 43cef4849f..2c07f77511 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -1266,7 +1266,7 @@ class TestPathname < Test::Unit::TestCase
open("f", "w") {|f| f.write "abc" }
Dir.chdir("/") {
assert_equal(
- [Pathname("."), Pathname(".."), Pathname("f")],
+ [Pathname("."), Pathname("f")],
Pathname.glob("*", File::FNM_DOTMATCH, base: dir).sort)
}
}
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index e5bcbeac73..bc91be4abf 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -165,7 +165,7 @@ class TestDir < Test::Unit::TestCase
end
def test_glob
- assert_equal((%w(. ..) + ("a".."z").to_a).map{|f| File.join(@root, f) },
+ assert_equal((%w(.) + ("a".."z").to_a).map{|f| File.join(@root, f) },
Dir.glob(File.join(@root, "*"), File::FNM_DOTMATCH))
assert_equal([@root] + ("a".."z").map {|f| File.join(@root, f) },
Dir.glob([@root, File.join(@root, "*")]))
@@ -203,6 +203,9 @@ class TestDir < Test::Unit::TestCase
Dir.chdir(@root) do
assert_include(Dir.glob("a/**/*", File::FNM_DOTMATCH), "a/.", bug8006)
+ Dir.mkdir("a/b")
+ assert_not_include(Dir.glob("a/**/*", File::FNM_DOTMATCH), "a/b/.")
+
FileUtils.mkdir_p("a/b/c/d/e/f")
assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/e/f"), bug6977)
assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/d/e/f"), bug6977)