diff options
author | Hiroshi Shirosaki <h.shirosaki@gmail.com> | 2022-10-18 09:18:03 +0900 |
---|---|---|
committer | Hiroshi Shirosaki <h.shirosaki@gmail.com> | 2022-10-18 09:18:03 +0900 |
commit | 329d5424a479bb08e75bd750c51a5382e382731c (patch) | |
tree | 63778980f4b7ef49446e2ac0d1b98eda0c85bb85 /test | |
parent | 995bdd69de0ce0ab5cec93c5818cc28912657458 (diff) |
[Bug #19042] Fix Dir.glob brace with '/'
Dir.glob brace pattern with '/' after '**' does not match
paths in recursive expansion process.
We expand braces with '/' before expanding a recursive.
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_dir.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 514c6e5921..ebbed75445 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -259,6 +259,20 @@ class TestDir < Test::Unit::TestCase end end + def test_glob_recursive_with_brace + Dir.chdir(@root) do + bug19042 = '[ruby-core:110220] [Bug #19042]' + %w"c/dir_a c/dir_b c/dir_b/dir".each do |d| + Dir.mkdir(d) + end + expected = %w"c/dir_a/file c/dir_b/dir/file" + expected.each do |f| + File.write(f, "") + end + assert_equal(expected, Dir.glob("**/{dir_a,dir_b/dir}/file"), bug19042) + end + end + def test_glob_order Dir.chdir(@root) do assert_equal(["#{@root}/a", "#{@root}/b"], Dir.glob("#{@root}/[ba]")) |