-
Notifications
You must be signed in to change notification settings - Fork 24
/
distignore.feature
383 lines (333 loc) · 12.2 KB
/
distignore.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# The "Examples" dataprovider is needed due to differences in zip and tar.
@require-php-7.1
Feature: Generate a distribution archive of a project
Scenario: Ignores backup files with a period and tilde
Given an empty directory
And a foo/.distignore file:
"""
.*~
"""
And a foo/test.php file:
"""
<?php
echo 'Hello world';
"""
And a foo/.testwithperiod.php file:
"""
<?php
echo 'Hello world';
"""
And a foo/.testwithtilde.php~after file:
"""
<?php
echo 'Hello world';
"""
And a foo/.test.php~ file:
"""
<?php
echo 'Hello world'; bak
"""
When I run `wp dist-archive foo`
Then STDOUT should match /^Success: Created foo.zip \(Size: \d+(?:\.\d*)? [a-zA-Z]{1,3}\)$/
When I run `rm -rf foo`
Then the foo directory should not exist
When I try `unzip foo.zip`
Then the foo directory should exist
And the foo/test.php file should exist
And the foo/.testwithperiod.php file should exist
And the foo/.testwithtilde.php~after file should exist
And the foo/.test.php~ file should not exist
Scenario Outline: Ignores hidden files in subdirectories
Given an empty directory
And a foo/.distignore file:
"""
.DS_Store
"""
And a foo/test.php file:
"""
<?php
echo 'Hello world;';
"""
And a foo/test-dir/test.php file:
"""
<?php
echo 'Hello world;';
"""
And a foo/test-dir/.DS_Store file:
"""
Bad!
"""
When I run `wp dist-archive foo --format=<format>`
Then STDOUT should match /^Success: Created foo.<extension> \(Size: \d+(?:\.\d*)? [a-zA-Z]{1,3}\)$/
And the foo.<extension> file should exist
When I run `rm -rf foo`
Then the foo directory should not exist
When I try `<extract> foo.<extension>`
Then the foo directory should exist
And the foo/test.php file should exist
And the foo/test-dir/test.php file should exist
And the foo/test-dir/.DS_Store file should not exist
Examples:
| format | extension | extract |
| zip | zip | unzip |
| targz | tar.gz | tar -zxvf |
Scenario Outline: Ignores .git folder
Given an empty directory
And a foo/.distignore file:
"""
.git
"""
And a foo/.git/version.control file:
"""
history
"""
And a foo/.git/subfolder/version.control file:
"""
history
"""
And a foo/plugin.php file:
"""
<?php
echo 'Hello world';
"""
Then the foo/.git directory should exist
Then the foo/.git/subfolder/version.control file should exist
When I run `wp dist-archive foo --format=<format>`
Then STDOUT should match /^Success: Created foo.<extension> \(Size: \d+(?:\.\d*)? [a-zA-Z]{1,3}\)$/
And the foo.<extension> file should exist
When I run `rm -rf foo`
Then the foo directory should not exist
When I try `<extract> foo.<extension>`
Then the foo directory should exist
And the foo/plugin.php file should exist
And the foo/.git directory should not exist
And the foo/.git/subfolder directory should not exist
And the foo/.git/version.control file should not exist
And the foo/.git/subfolder/version.control file should not exist
Examples:
| format | extension | extract |
| zip | zip | unzip |
| targz | tar.gz | tar -zxvf |
Scenario Outline: Ignores files specified with absolute path and not similarly named files
Given an empty directory
And a foo/.distignore file:
"""
/maybe-ignore-me.txt
"""
And a foo/test.php file:
"""
<?php
echo 'Hello world;';
"""
And a foo/test-dir/test.php file:
"""
<?php
echo 'Hello world;';
"""
And a foo/maybe-ignore-me.txt file:
"""
Ignore
"""
And a foo/test-dir/maybe-ignore-me.txt file:
"""
Do not ignore
"""
And a foo/test-dir/foo/maybe-ignore-me.txt file:
"""
Do not ignore
"""
When I run `wp dist-archive foo --format=<format> --plugin-dirname=<plugin-dirname>`
Then STDOUT should match /^Success: Created <plugin-dirname>.<extension> \(Size: \d+(?:\.\d*)? [a-zA-Z]{1,3}\)$/
And the <plugin-dirname>.<extension> file should exist
When I run `rm -rf foo`
Then the foo directory should not exist
When I run `rm -rf <plugin-dirname>`
Then the <plugin-dirname> directory should not exist
When I try `<extract> <plugin-dirname>.<extension>`
Then the <plugin-dirname> directory should exist
And the <plugin-dirname>/test.php file should exist
And the <plugin-dirname>/test-dir/test.php file should exist
And the <plugin-dirname>/maybe-ignore-me.txt file should not exist
And the <plugin-dirname>/test-dir/maybe-ignore-me.txt file should exist
And the <plugin-dirname>/test-dir/foo/maybe-ignore-me.txt file should exist
Examples:
| format | extension | extract | plugin-dirname |
| zip | zip | unzip | foo |
| targz | tar.gz | tar -zxvf | foo |
| zip | zip | unzip | bar |
| targz | tar.gz | tar -zxvf | bar2 |
Scenario Outline: Correctly ignores hidden files when specified in distignore
Given an empty directory
And a foo/.distignore file:
"""
.*
"""
And a foo/.hidden file:
"""
Ignore
"""
And a foo/test-dir/.hidden file:
"""
Ignore
"""
And a foo/not.hidden file:
"""
Do not ignore
"""
And a foo/test-dir/not.hidden file:
"""
Do not ignore
"""
When I run `wp dist-archive foo --format=<format> --plugin-dirname=<plugin-dirname>`
Then STDOUT should match /^Success: Created <plugin-dirname>.<extension> \(Size: \d+(?:\.\d*)? [a-zA-Z]{1,3}\)$/
And the <plugin-dirname>.<extension> file should exist
When I run `rm -rf foo`
Then the foo directory should not exist
When I run `rm -rf <plugin-dirname>`
Then the <plugin-dirname> directory should not exist
When I try `<extract> <plugin-dirname>.<extension>`
Then the <plugin-dirname> directory should exist
And the <plugin-dirname>/.hidden file should not exist
And the <plugin-dirname>/not.hidden file should exist
And the <plugin-dirname>/test-dir/.hidden file should not exist
And the <plugin-dirname>/test-dir/not.hidden file should exist
Examples:
| format | extension | extract | plugin-dirname |
| zip | zip | unzip | foo |
| targz | tar.gz | tar -zxvf | foo |
| zip | zip | unzip | bar3 |
| targz | tar.gz | tar -zxvf | bar4 |
Scenario Outline: Ignores files with exact match and not similarly named files
Given an empty directory
And a foo/.distignore file:
"""
ignore-me.js
"""
And a foo/test.php file:
"""
<?php
echo 'Hello world;';
"""
And a foo/ignore-me.json file:
"""
Do not ignore
"""
And a foo/ignore-me.js file:
"""
Ignore
"""
When I run `wp dist-archive foo --format=<format> --plugin-dirname=<plugin-dirname>`
Then STDOUT should match /^Success: Created <plugin-dirname>.<extension> \(Size: \d+(?:\.\d*)? [a-zA-Z]{1,3}\)$/
And the <plugin-dirname>.<extension> file should exist
When I run `rm -rf foo`
Then the foo directory should not exist
When I run `rm -rf <plugin-dirname>`
Then the <plugin-dirname> directory should not exist
When I try `<extract> <plugin-dirname>.<extension>`
Then the <plugin-dirname> directory should exist
And the <plugin-dirname>/test.php file should exist
And the <plugin-dirname>/ignore-me.json file should exist
And the <plugin-dirname>/ignore-me.js file should not exist
Examples:
| format | extension | extract | plugin-dirname |
| zip | zip | unzip | foo |
| targz | tar.gz | tar -zxvf | foo |
| zip | zip | unzip | bar |
| targz | tar.gz | tar -zxvf | bar2 |
Scenario Outline: Ignores files in ignored directory except subdirectory excluded from exclusion: `!/frontend/build/`
# @see https://github.com/wp-cli/dist-archive-command/issues/44#issue-917541953
Given an empty directory
And a foo/test.php file:
"""
<?php
echo 'Hello world;';
"""
And a foo/.distignore file:
"""
frontend/*
!/frontend/build/
"""
And a foo/frontend/test.ts file:
"""
excludeme
"""
And a foo/frontend/build/test.js file:
"""
includeme
"""
When I run `wp dist-archive foo --format=<format> --plugin-dirname=<plugin-dirname>`
Then STDOUT should match /^Success: Created <plugin-dirname>.<extension> \(Size: \d+(?:\.\d*)? [a-zA-Z]{1,3}\)$/
And the <plugin-dirname>.<extension> file should exist
When I run `mv foo sourcefoo`
Then the foo directory should not exist
When I run `rm -rf <plugin-dirname>`
Then the <plugin-dirname> directory should not exist
When I try `<extract> <plugin-dirname>.<extension>`
Then the <plugin-dirname> directory should exist
And the <plugin-dirname>/test.php file should exist
And the <plugin-dirname>/frontend/test.ts file should not exist
And the <plugin-dirname>/frontend/build/test.js file should exist
Examples:
| format | extension | extract | plugin-dirname |
| zip | zip | unzip | foo |
| targz | tar.gz | tar -zxvf | foo |
| zip | zip | unzip | bar5 |
| targz | tar.gz | tar -zxvf | bar6 |
Scenario Outline: Ignores files matching pattern in all subdirectories of explicit directory: `blocks/src/block/**/*.js`
# @see https://github.com/wp-cli/dist-archive-command/issues/44#issuecomment-1677135516
Given an empty directory
And a foo/.distignore file:
"""
blocks/src/block/**/*.ts
"""
And a foo/blocks/src/block/level1/test.ts file:
"""
excludeme
"""
And a foo/blocks/src/block/level1/test.js file:
"""
includeme
"""
And a foo/blocks/src/block/level1/level2/test.ts file:
"""
excludeme
"""
And a foo/blocks/src/block/level1/level2/test.js file:
"""
includeme
"""
When I run `wp dist-archive foo --format=<format> --plugin-dirname=<plugin-dirname>`
Then STDOUT should match /^Success: Created <plugin-dirname>.<extension> \(Size: \d+(?:\.\d*)? [a-zA-Z]{1,3}\)$/
And the <plugin-dirname>.<extension> file should exist
When I run `mv foo sourcefoo`
Then the foo directory should not exist
When I run `rm -rf <plugin-dirname>`
Then the <plugin-dirname> directory should not exist
When I try `<extract> <plugin-dirname>.<extension>`
Then the <plugin-dirname> directory should exist
And the <plugin-dirname>/blocks/src/block/level1/test.ts file should not exist
And the <plugin-dirname>/blocks/src/block/level1/test.js file should exist
And the <plugin-dirname>/blocks/src/block/level1/level2/test.ts file should not exist
And the <plugin-dirname>/blocks/src/block/level1/level2/test.js file should exist
Examples:
| format | extension | extract | plugin-dirname |
| zip | zip | unzip | foo |
| targz | tar.gz | tar -zxvf | foo |
| zip | zip | unzip | bar7 |
| targz | tar.gz | tar -zxvf | bar8 |
Scenario: Does not crash when a broken symlink is encountered
# @see https://github.com/wp-cli/dist-archive-command/issues/86
Given an empty directory
And an empty foo/target-directory directory
And a foo/.distignore file:
"""
"""
When I run `ln -s {RUN_DIR}/foo/target-directory {RUN_DIR}/foo/symlink`
Then STDERR should be empty
When I run `rm -rf {RUN_DIR}/foo/target-directory`
Then STDERR should be empty
When I try `wp dist-archive foo`
Then STDERR should contain:
"""
Error: Broken symlink at /symlink. Target missing at
"""