@@ -42,7 +42,7 @@ func TestReadDirRecursive(t *testing.T) {
42
42
43
43
list , err := testPath .ReadDirRecursive ()
44
44
require .NoError (t , err )
45
- require .Len (t , list , 16 )
45
+ require .Len (t , list , 25 )
46
46
47
47
pathEqualsTo (t , "_testdata/anotherFile" , list [0 ])
48
48
pathEqualsTo (t , "_testdata/file" , list [1 ])
@@ -52,14 +52,25 @@ func TestReadDirRecursive(t *testing.T) {
52
52
pathEqualsTo (t , "_testdata/folder/file3" , list [5 ])
53
53
pathEqualsTo (t , "_testdata/folder/subfolder" , list [6 ])
54
54
pathEqualsTo (t , "_testdata/folder/subfolder/file4" , list [7 ])
55
- pathEqualsTo (t , "_testdata/symlinktofolder" , list [8 ])
56
- pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , list [9 ])
57
- pathEqualsTo (t , "_testdata/symlinktofolder/file2" , list [10 ])
58
- pathEqualsTo (t , "_testdata/symlinktofolder/file3" , list [11 ])
59
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , list [12 ])
60
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , list [13 ])
61
- pathEqualsTo (t , "_testdata/test.txt" , list [14 ])
62
- pathEqualsTo (t , "_testdata/test.txt.gz" , list [15 ])
55
+
56
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks" , list [8 ])
57
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/file" , list [9 ])
58
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/file2" , list [10 ])
59
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder" , list [11 ])
60
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/.hidden" , list [12 ])
61
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/file2" , list [13 ])
62
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/file3" , list [14 ])
63
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/subfolder" , list [15 ])
64
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/subfolder/file4" , list [16 ])
65
+
66
+ pathEqualsTo (t , "_testdata/symlinktofolder" , list [17 ])
67
+ pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , list [18 ])
68
+ pathEqualsTo (t , "_testdata/symlinktofolder/file2" , list [19 ])
69
+ pathEqualsTo (t , "_testdata/symlinktofolder/file3" , list [20 ])
70
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , list [21 ])
71
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , list [22 ])
72
+ pathEqualsTo (t , "_testdata/test.txt" , list [23 ])
73
+ pathEqualsTo (t , "_testdata/test.txt.gz" , list [24 ])
63
74
}
64
75
65
76
func TestReadDirRecursiveSymLinkLoop (t * testing.T ) {
@@ -110,7 +121,7 @@ func TestReadDirRecursiveFiltered(t *testing.T) {
110
121
l , err := testdata .ReadDirRecursiveFiltered (nil )
111
122
require .NoError (t , err )
112
123
l .Sort ()
113
- require .Len (t , l , 16 )
124
+ require .Len (t , l , 25 )
114
125
pathEqualsTo (t , "_testdata/anotherFile" , l [0 ])
115
126
pathEqualsTo (t , "_testdata/file" , l [1 ])
116
127
pathEqualsTo (t , "_testdata/folder" , l [2 ])
@@ -119,42 +130,62 @@ func TestReadDirRecursiveFiltered(t *testing.T) {
119
130
pathEqualsTo (t , "_testdata/folder/file3" , l [5 ])
120
131
pathEqualsTo (t , "_testdata/folder/subfolder" , l [6 ])
121
132
pathEqualsTo (t , "_testdata/folder/subfolder/file4" , l [7 ])
122
- pathEqualsTo (t , "_testdata/symlinktofolder" , l [8 ])
123
- pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [9 ])
124
- pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [10 ])
125
- pathEqualsTo (t , "_testdata/symlinktofolder/file3" , l [11 ])
126
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [12 ])
127
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , l [13 ])
128
- pathEqualsTo (t , "_testdata/test.txt" , l [14 ])
129
- pathEqualsTo (t , "_testdata/test.txt.gz" , l [15 ])
133
+
134
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks" , l [8 ])
135
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/file" , l [9 ])
136
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/file2" , l [10 ])
137
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder" , l [11 ])
138
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/.hidden" , l [12 ])
139
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/file2" , l [13 ])
140
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/file3" , l [14 ])
141
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/subfolder" , l [15 ])
142
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/subfolder/file4" , l [16 ])
143
+
144
+ pathEqualsTo (t , "_testdata/symlinktofolder" , l [17 ])
145
+ pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [18 ])
146
+ pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [19 ])
147
+ pathEqualsTo (t , "_testdata/symlinktofolder/file3" , l [20 ])
148
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [21 ])
149
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , l [22 ])
150
+ pathEqualsTo (t , "_testdata/test.txt" , l [23 ])
151
+ pathEqualsTo (t , "_testdata/test.txt.gz" , l [24 ])
130
152
131
153
l , err = testdata .ReadDirRecursiveFiltered (FilterOutDirectories ())
132
154
require .NoError (t , err )
133
155
l .Sort ()
134
- require .Len (t , l , 6 )
156
+ require .Len (t , l , 7 )
135
157
pathEqualsTo (t , "_testdata/anotherFile" , l [0 ])
136
158
pathEqualsTo (t , "_testdata/file" , l [1 ])
137
- pathEqualsTo (t , "_testdata/folder" , l [2 ]) // <- this is listed but not traversed
138
- pathEqualsTo (t , "_testdata/symlinktofolder" , l [3 ]) // <- this is listed but not traversed
139
- pathEqualsTo (t , "_testdata/test.txt" , l [4 ])
140
- pathEqualsTo (t , "_testdata/test.txt.gz" , l [5 ])
159
+ pathEqualsTo (t , "_testdata/folder" , l [2 ]) // <- this is listed but not traversed
160
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks" , l [3 ]) // <- this is listed but not traversed
161
+ pathEqualsTo (t , "_testdata/symlinktofolder" , l [4 ]) // <- this is listed but not traversed
162
+ pathEqualsTo (t , "_testdata/test.txt" , l [5 ])
163
+ pathEqualsTo (t , "_testdata/test.txt.gz" , l [6 ])
141
164
142
165
l , err = testdata .ReadDirRecursiveFiltered (nil , FilterOutDirectories ())
143
166
require .NoError (t , err )
144
167
l .Sort ()
145
- require .Len (t , l , 12 )
168
+ require .Len (t , l , 18 )
146
169
pathEqualsTo (t , "_testdata/anotherFile" , l [0 ])
147
170
pathEqualsTo (t , "_testdata/file" , l [1 ])
148
171
pathEqualsTo (t , "_testdata/folder/.hidden" , l [2 ])
149
172
pathEqualsTo (t , "_testdata/folder/file2" , l [3 ])
150
173
pathEqualsTo (t , "_testdata/folder/file3" , l [4 ])
151
174
pathEqualsTo (t , "_testdata/folder/subfolder/file4" , l [5 ])
152
- pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [6 ])
153
- pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [7 ])
154
- pathEqualsTo (t , "_testdata/symlinktofolder/file3" , l [8 ])
155
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , l [9 ])
156
- pathEqualsTo (t , "_testdata/test.txt" , l [10 ])
157
- pathEqualsTo (t , "_testdata/test.txt.gz" , l [11 ])
175
+
176
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/file" , l [6 ])
177
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/file2" , l [7 ])
178
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/.hidden" , l [8 ])
179
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/file2" , l [9 ])
180
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/file3" , l [10 ])
181
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/subfolder/file4" , l [11 ])
182
+
183
+ pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [12 ])
184
+ pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [13 ])
185
+ pathEqualsTo (t , "_testdata/symlinktofolder/file3" , l [14 ])
186
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , l [15 ])
187
+ pathEqualsTo (t , "_testdata/test.txt" , l [16 ])
188
+ pathEqualsTo (t , "_testdata/test.txt.gz" , l [17 ])
158
189
159
190
l , err = testdata .ReadDirRecursiveFiltered (FilterOutDirectories (), FilterOutDirectories ())
160
191
require .NoError (t , err )
@@ -168,80 +199,104 @@ func TestReadDirRecursiveFiltered(t *testing.T) {
168
199
l , err = testdata .ReadDirRecursiveFiltered (FilterOutPrefixes ("sub" ), FilterOutSuffixes ("3" ))
169
200
require .NoError (t , err )
170
201
l .Sort ()
171
- require .Len (t , l , 12 )
202
+ require .Len (t , l , 19 )
172
203
pathEqualsTo (t , "_testdata/anotherFile" , l [0 ])
173
204
pathEqualsTo (t , "_testdata/file" , l [1 ])
174
205
pathEqualsTo (t , "_testdata/folder" , l [2 ])
175
206
pathEqualsTo (t , "_testdata/folder/.hidden" , l [3 ])
176
207
pathEqualsTo (t , "_testdata/folder/file2" , l [4 ])
177
208
pathEqualsTo (t , "_testdata/folder/subfolder" , l [5 ]) // <- subfolder skipped by Prefix("sub")
178
- pathEqualsTo (t , "_testdata/symlinktofolder" , l [6 ])
179
- pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [7 ])
180
- pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [8 ])
181
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [9 ]) // <- subfolder skipped by Prefix("sub")
182
- pathEqualsTo (t , "_testdata/test.txt" , l [10 ])
183
- pathEqualsTo (t , "_testdata/test.txt.gz" , l [11 ])
209
+
210
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks" , l [6 ])
211
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/file" , l [7 ])
212
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/file2" , l [8 ])
213
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder" , l [9 ])
214
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/.hidden" , l [10 ])
215
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/file2" , l [11 ])
216
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/subfolder" , l [12 ]) // <- subfolder skipped by Prefix("sub")
217
+
218
+ pathEqualsTo (t , "_testdata/symlinktofolder" , l [13 ])
219
+ pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [14 ])
220
+ pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [15 ])
221
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [16 ]) // <- subfolder skipped by Prefix("sub")
222
+ pathEqualsTo (t , "_testdata/test.txt" , l [17 ])
223
+ pathEqualsTo (t , "_testdata/test.txt.gz" , l [18 ])
184
224
185
225
l , err = testdata .ReadDirRecursiveFiltered (FilterOutPrefixes ("sub" ), AndFilter (FilterOutSuffixes ("3" ), FilterOutPrefixes ("fil" )))
186
226
require .NoError (t , err )
187
227
l .Sort ()
188
- require .Len (t , l , 9 )
228
+ require .Len (t , l , 13 )
189
229
pathEqualsTo (t , "_testdata/anotherFile" , l [0 ])
190
230
pathEqualsTo (t , "_testdata/folder" , l [1 ])
191
231
pathEqualsTo (t , "_testdata/folder/.hidden" , l [2 ])
192
232
pathEqualsTo (t , "_testdata/folder/subfolder" , l [3 ])
193
- pathEqualsTo (t , "_testdata/symlinktofolder" , l [4 ])
194
- pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [5 ])
195
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [6 ])
196
- pathEqualsTo (t , "_testdata/test.txt" , l [7 ])
197
- pathEqualsTo (t , "_testdata/test.txt.gz" , l [8 ])
233
+
234
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks" , l [4 ])
235
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder" , l [5 ])
236
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/.hidden" , l [6 ])
237
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/subfolder" , l [7 ])
238
+
239
+ pathEqualsTo (t , "_testdata/symlinktofolder" , l [8 ])
240
+ pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [9 ])
241
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [10 ])
242
+ pathEqualsTo (t , "_testdata/test.txt" , l [11 ])
243
+ pathEqualsTo (t , "_testdata/test.txt.gz" , l [12 ])
198
244
199
245
l , err = testdata .ReadDirRecursiveFiltered (FilterOutPrefixes ("sub" ), AndFilter (FilterOutSuffixes ("3" ), FilterOutPrefixes ("fil" ), FilterOutSuffixes (".gz" )))
200
246
require .NoError (t , err )
201
247
l .Sort ()
202
- require .Len (t , l , 8 )
248
+ require .Len (t , l , 12 )
203
249
pathEqualsTo (t , "_testdata/anotherFile" , l [0 ])
204
250
pathEqualsTo (t , "_testdata/folder" , l [1 ])
205
251
pathEqualsTo (t , "_testdata/folder/.hidden" , l [2 ])
206
252
pathEqualsTo (t , "_testdata/folder/subfolder" , l [3 ])
207
- pathEqualsTo (t , "_testdata/symlinktofolder" , l [4 ])
208
- pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [5 ])
209
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [6 ])
210
- pathEqualsTo (t , "_testdata/test.txt" , l [7 ])
253
+
254
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks" , l [4 ])
255
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder" , l [5 ])
256
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/.hidden" , l [6 ])
257
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder/subfolder" , l [7 ])
258
+
259
+ pathEqualsTo (t , "_testdata/symlinktofolder" , l [8 ])
260
+ pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [9 ])
261
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [10 ])
262
+ pathEqualsTo (t , "_testdata/test.txt" , l [11 ])
211
263
212
264
l , err = testdata .ReadDirRecursiveFiltered (OrFilter (FilterPrefixes ("sub" ), FilterSuffixes ("tofolder" )))
213
265
require .NoError (t , err )
214
266
l .Sort ()
215
- require .Len (t , l , 11 )
267
+ require .Len (t , l , 12 )
216
268
pathEqualsTo (t , "_testdata/anotherFile" , l [0 ])
217
269
pathEqualsTo (t , "_testdata/file" , l [1 ])
218
270
pathEqualsTo (t , "_testdata/folder" , l [2 ])
219
- pathEqualsTo (t , "_testdata/symlinktofolder" , l [3 ])
220
- pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [4 ])
221
- pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [5 ])
222
- pathEqualsTo (t , "_testdata/symlinktofolder/file3" , l [6 ])
223
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [7 ])
224
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , l [8 ])
225
- pathEqualsTo (t , "_testdata/test.txt" , l [9 ])
226
- pathEqualsTo (t , "_testdata/test.txt.gz" , l [10 ])
271
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks" , l [3 ])
272
+ pathEqualsTo (t , "_testdata/symlinktofolder" , l [4 ])
273
+ pathEqualsTo (t , "_testdata/symlinktofolder/.hidden" , l [5 ])
274
+ pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [6 ])
275
+ pathEqualsTo (t , "_testdata/symlinktofolder/file3" , l [7 ])
276
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [8 ])
277
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder/file4" , l [9 ])
278
+ pathEqualsTo (t , "_testdata/test.txt" , l [10 ])
279
+ pathEqualsTo (t , "_testdata/test.txt.gz" , l [11 ])
227
280
228
281
l , err = testdata .ReadDirRecursiveFiltered (nil , FilterNames ("folder" ))
229
282
require .NoError (t , err )
230
283
l .Sort ()
231
- require .Len (t , l , 1 )
284
+ require .Len (t , l , 2 )
232
285
pathEqualsTo (t , "_testdata/folder" , l [0 ])
286
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks/folder" , l [1 ])
233
287
234
288
l , err = testdata .ReadDirRecursiveFiltered (FilterNames ("symlinktofolder" ), FilterOutNames (".hidden" ))
235
289
require .NoError (t , err )
236
- require .Len (t , l , 9 )
290
+ require .Len (t , l , 10 )
237
291
l .Sort ()
238
292
pathEqualsTo (t , "_testdata/anotherFile" , l [0 ])
239
293
pathEqualsTo (t , "_testdata/file" , l [1 ])
240
294
pathEqualsTo (t , "_testdata/folder" , l [2 ])
241
- pathEqualsTo (t , "_testdata/symlinktofolder" , l [3 ])
242
- pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [4 ])
243
- pathEqualsTo (t , "_testdata/symlinktofolder/file3" , l [5 ])
244
- pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [6 ])
245
- pathEqualsTo (t , "_testdata/test.txt" , l [7 ])
246
- pathEqualsTo (t , "_testdata/test.txt.gz" , l [8 ])
295
+ pathEqualsTo (t , "_testdata/folder_containing_symlinks" , l [3 ])
296
+ pathEqualsTo (t , "_testdata/symlinktofolder" , l [4 ])
297
+ pathEqualsTo (t , "_testdata/symlinktofolder/file2" , l [5 ])
298
+ pathEqualsTo (t , "_testdata/symlinktofolder/file3" , l [6 ])
299
+ pathEqualsTo (t , "_testdata/symlinktofolder/subfolder" , l [7 ])
300
+ pathEqualsTo (t , "_testdata/test.txt" , l [8 ])
301
+ pathEqualsTo (t , "_testdata/test.txt.gz" , l [9 ])
247
302
}
0 commit comments