Skip to content

Commit 72d1f41

Browse files
committed
[GR-18163] Fix missing glob entries dot subdirectories when using **/* with FNM_DOTMATCH
PullRequest: truffleruby/2052
2 parents 8eca629 + c492737 commit 72d1f41

File tree

5 files changed

+24
-1
lines changed

5 files changed

+24
-1
lines changed

spec/ruby/core/dir/fixtures/common.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def self.mock_dir_files
3636
.dotfile
3737
.dotsubdir/.dotfile
3838
.dotsubdir/nondotfile
39+
nested/.dotsubir/.dotfile
40+
nested/.dotsubir/nondotfile
3941

4042
deeply/.dotfile
4143
deeply/nested/.dotfile.ext
@@ -160,6 +162,7 @@ def self.expected_paths
160162
dir_filename_ordering
161163
file_one.ext
162164
file_two.ext
165+
nested
163166
nondotfile
164167
special
165168
subdir_one

spec/ruby/core/dir/glob_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
deeply/nested/directory/
6060
deeply/nested/directory/structure/
6161
dir/
62+
nested/
63+
nested/.dotsubir/
6264
special/
6365
special/test{1}/
6466
subdir_one/
@@ -68,6 +70,18 @@
6870
Dir.glob('**/', File::FNM_DOTMATCH).sort.should == expected
6971
end
7072

73+
it "recursively matches files and directories in nested dot subdirectory with 'nested/**/*' from the current directory and option File::FNM_DOTMATCH" do
74+
expected = %w[
75+
nested/.
76+
nested/.dotsubir
77+
nested/.dotsubir/.
78+
nested/.dotsubir/.dotfile
79+
nested/.dotsubir/nondotfile
80+
]
81+
82+
Dir.glob('nested/**/*', File::FNM_DOTMATCH).sort.should == expected.sort
83+
end
84+
7185
# This is a separate case to check **/ coming after a constant
7286
# directory as well.
7387
it "recursively matches any subdirectories except './' or '../' with '**/' and option File::FNM_DOTMATCH" do
@@ -80,6 +94,8 @@
8094
./deeply/nested/directory/
8195
./deeply/nested/directory/structure/
8296
./dir/
97+
./nested/
98+
./nested/.dotsubir/
8399
./special/
84100
./special/test{1}/
85101
./subdir_one/

spec/ruby/core/dir/shared/glob.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
dir_filename_ordering
5454
file_one.ext
5555
file_two.ext
56+
nested
5657
nondotfile
5758
special
5859
subdir_one
@@ -156,6 +157,7 @@
156157
dir_filename_ordering
157158
file_one.ext
158159
file_two.ext
160+
nested
159161
nondotfile
160162
special
161163
subdir_one
@@ -177,6 +179,7 @@
177179
deeply/nested/directory/
178180
deeply/nested/directory/structure/
179181
dir/
182+
nested/
180183
special/
181184
special/test{1}/
182185
subdir_one/

spec/tags/core/dir/glob_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
fails:Dir.glob recursively matches files and directories in nested dot subdirectory with 'nested/**/*' from the current directory and option File::FNM_DOTMATCH

src/main/ruby/truffleruby/core/dir_glob.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def call(matches, start, glob_base_dir)
163163
full = path_join(path, ent)
164164
mode = Truffle::POSIX.truffleposix_lstat_mode(path_join(glob_base_dir, full))
165165

166-
if Truffle::StatOperations.directory?(mode) and ent.getbyte(0) != 46 # ?.
166+
if Truffle::StatOperations.directory?(mode) and (allow_dots or ent.getbyte(0) != 46) # ?.
167167
stack << full
168168
@next.call matches, full, glob_base_dir
169169
end

0 commit comments

Comments
 (0)