mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
dir.c: fix Dir.glob with braces and matching dir
* dir.c (join_path_from_pattern): add the last slash for directory matching. * test/ruby/test_dir.rb (test_glob_recursive_directory): add a test for above. [ruby-core:91110] [Bug #15540] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
74477ec2b3
commit
d1417ff8fa
2 changed files with 18 additions and 0 deletions
4
dir.c
4
dir.c
|
@ -2052,6 +2052,10 @@ join_path_from_pattern(struct glob_pattern **beg)
|
||||||
case RECURSIVE:
|
case RECURSIVE:
|
||||||
str = "**";
|
str = "**";
|
||||||
break;
|
break;
|
||||||
|
case MATCH_DIR:
|
||||||
|
/* append last slash */
|
||||||
|
str = "";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
str = p->str;
|
str = p->str;
|
||||||
if (!str) continue;
|
if (!str) continue;
|
||||||
|
|
|
@ -191,6 +191,20 @@ class TestDir < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_glob_recursive_directory
|
||||||
|
Dir.chdir(@root) do
|
||||||
|
['d', 'e'].each do |path|
|
||||||
|
FileUtils.mkdir_p("c/#{path}/a/b/c")
|
||||||
|
FileUtils.touch("c/#{path}/a/a.file")
|
||||||
|
FileUtils.touch("c/#{path}/a/b/b.file")
|
||||||
|
FileUtils.touch("c/#{path}/a/b/c/c.file")
|
||||||
|
end
|
||||||
|
bug15540 = '[ruby-core:91110] [Bug #15540]'
|
||||||
|
assert_equal(["c/d/a/", "c/d/a/b/", "c/d/a/b/c/", "c/e/a/", "c/e/a/b/", "c/e/a/b/c/"],
|
||||||
|
Dir.glob('c/{d,e}/a/**/'), bug15540)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if Process.const_defined?(:RLIMIT_NOFILE)
|
if Process.const_defined?(:RLIMIT_NOFILE)
|
||||||
def test_glob_too_may_open_files
|
def test_glob_too_may_open_files
|
||||||
assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}", chdir: @root)
|
assert_separately([], "#{<<-"begin;"}\n#{<<-'end;'}", chdir: @root)
|
||||||
|
|
Loading…
Add table
Reference in a new issue