~bmerry/duplicity/pydrive-id-cache

« back to all changes in this revision

Viewing changes to testing/unit/test_selection.py

* Merged in lp:~aaron-whitehouse/duplicity/filelist_combine
  - Merged globbing and non-globbing filelists to use the same code path
    and all accept globbing characters. Added deprecation warning to the
    --exclude-globbing-filelist and include-globbing-filelist options in
    commandline.py and hid them from help output. Updated the manual
    (and unit tests) accordingly.
  - Note that this does trigger a change in behaviour for duplicity.
    Previously, include patterns in include-filelist did not match files
    in a directory that was included, so /usr/local in an include file
    would not have matched /usr/local/doc. Now, this folder would be
    included, as would occur if --include or the old
    --include-globbing-filelist was used. Additional lines will therefore
    need to be added to filelists to unambiguously exclude unwanted
    subfolders, if this is intended.
  - Mark --include-filelist-stdin and --exclude-fielist-stdin for
    deprecation and hide from --help output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
102
102
        assert sf2(self.makeext("what/ever.py")) == 0
103
103
        assert sf2(self.makeext("what/ever.py/foo")) == 0
104
104
 
105
 
    def testFilelistInclude(self):
106
 
        """Test included filelist"""
107
 
        fp = StringIO.StringIO("""
108
 
testfiles/select/1/2
109
 
testfiles/select/1
110
 
testfiles/select/1/2/3
111
 
testfiles/select/3/3/2""")
112
 
        sf = self.Select.filelist_get_sf(fp, 1, "test")
113
 
        assert sf(self.root) == 1
114
 
        assert sf(self.makeext("1")) == 1
115
 
        assert sf(self.makeext("1/1")) is None
116
 
        assert sf(self.makeext("1/2/3")) == 1
117
 
        assert sf(self.makeext("2/2")) is None
118
 
        assert sf(self.makeext("3")) == 1
119
 
        assert sf(self.makeext("3/3")) == 1
120
 
        assert sf(self.makeext("3/3/3")) is None
121
 
 
122
 
    def test_filelist_include_1_trailing_white_space(self):
123
 
        """Test trailing whitespace is ignored in included filelist (1 space)"""
124
 
        fp = StringIO.StringIO("testfiles/select/1/2\n"
125
 
                               "testfiles/select/1 \n"
126
 
                               "testfiles/select/1/2/3\n"
127
 
                               "testfiles/select/3/3/2")
128
 
        sf = self.Select.filelist_get_sf(fp, 1, "test")
129
 
        assert sf(self.root) == 1
130
 
        assert sf(self.makeext("1")) == 1
131
 
        assert sf(self.makeext("1/1")) is None
132
 
        assert sf(self.makeext("1/2/3")) == 1
133
 
        assert sf(self.makeext("2/2")) is None
134
 
        assert sf(self.makeext("3")) == 1
135
 
        assert sf(self.makeext("3/3")) == 1
136
 
        assert sf(self.makeext("3/3/3")) is None
137
 
 
138
 
    def test_filelist_include_2_trailing_white_spaces(self):
139
 
        """Test trailing whitespace is ignored in included filelist (2 space)"""
140
 
        fp = StringIO.StringIO("testfiles/select/1/2\n"
141
 
                               "testfiles/select/1\n"
142
 
                               "testfiles/select/1/2/3  \n"
143
 
                               "testfiles/select/3/3/2")
144
 
        sf = self.Select.filelist_get_sf(fp, 1, "test")
145
 
        assert sf(self.root) == 1
146
 
        assert sf(self.makeext("1")) == 1
147
 
        assert sf(self.makeext("1/1")) is None
148
 
        assert sf(self.makeext("1/2/3")) == 1
149
 
        assert sf(self.makeext("2/2")) is None
150
 
        assert sf(self.makeext("3")) == 1
151
 
        assert sf(self.makeext("3/3")) == 1
152
 
        assert sf(self.makeext("3/3/3")) is None
153
 
 
154
 
    def test_filelist_include_1_leading_white_space(self):
155
 
        """Test leading whitespace is ignored in included filelist (1 space)"""
156
 
        fp = StringIO.StringIO(" testfiles/select/1/2\n"
157
 
                               "testfiles/select/1\n"
158
 
                               "testfiles/select/1/2/3\n"
159
 
                               "testfiles/select/3/3/2")
160
 
        sf = self.Select.filelist_get_sf(fp, 1, "test")
161
 
        assert sf(self.root) == 1
162
 
        assert sf(self.makeext("1")) == 1
163
 
        assert sf(self.makeext("1/1")) is None
164
 
        assert sf(self.makeext("1/2/3")) == 1
165
 
        assert sf(self.makeext("2/2")) is None
166
 
        assert sf(self.makeext("3")) == 1
167
 
        assert sf(self.makeext("3/3")) == 1
168
 
        assert sf(self.makeext("3/3/3")) is None
169
 
 
170
 
    def test_filelist_include_2_leading_white_spaces(self):
171
 
        """Test leading whitespace is ignored in included filelist (1 space)"""
172
 
        fp = StringIO.StringIO("testfiles/select/1/2\n"
173
 
                               "testfiles/select/1\n"
174
 
                               "testfiles/select/1/2/3\n"
175
 
                               "  testfiles/select/3/3/2")
176
 
        sf = self.Select.filelist_get_sf(fp, 1, "test")
177
 
        assert sf(self.root) == 1
178
 
        assert sf(self.makeext("1")) == 1
179
 
        assert sf(self.makeext("1/1")) is None
180
 
        assert sf(self.makeext("1/2/3")) == 1
181
 
        assert sf(self.makeext("2/2")) is None
182
 
        assert sf(self.makeext("3")) == 1
183
 
        assert sf(self.makeext("3/3")) == 1
184
 
        assert sf(self.makeext("3/3/3")) is None
185
 
 
186
 
    def testFilelistIncludeNullSep(self):
187
 
        """Test included filelist but with null_separator set"""
188
 
        fp = StringIO.StringIO("""\0testfiles/select/1/2\0testfiles/select/1\0testfiles/select/1/2/3\0testfiles/select/3/3/2\0testfiles/select/hello\nthere\0""")
189
 
        self.set_global('null_separator', 1)
190
 
        sf = self.Select.filelist_get_sf(fp, 1, "test")
191
 
        assert sf(self.root) == 1
192
 
        assert sf(self.makeext("1")) == 1
193
 
        assert sf(self.makeext("1/1")) is None
194
 
        assert sf(self.makeext("1/2/3")) == 1
195
 
        assert sf(self.makeext("2/2")) is None
196
 
        assert sf(self.makeext("3")) == 1
197
 
        assert sf(self.makeext("3/3")) == 1
198
 
        assert sf(self.makeext("3/3/3")) is None
199
 
        assert sf(self.makeext("hello\nthere")) == 1
200
 
 
201
 
    def testFilelistExclude(self):
202
 
        """Test included filelist"""
203
 
        fp = StringIO.StringIO("""
204
 
testfiles/select/1/2
205
 
testfiles/select/1
206
 
this is a badly formed line which should be ignored
207
 
 
208
 
testfiles/select/1/2/3
209
 
testfiles/select/3/3/2""")
210
 
        sf = self.Select.filelist_get_sf(fp, 0, "test")
211
 
        assert sf(self.root) is None
212
 
        assert sf(self.makeext("1")) == 0
213
 
        assert sf(self.makeext("1/1")) == 0
214
 
        assert sf(self.makeext("1/2/3")) == 0
215
 
        assert sf(self.makeext("2/2")) is None
216
 
        assert sf(self.makeext("3")) is None
217
 
        assert sf(self.makeext("3/3/2")) == 0
218
 
        assert sf(self.makeext("3/3/3")) is None
219
 
 
220
 
    def testFilelistInclude2(self):
221
 
        """testFilelistInclude2 - with modifiers"""
222
 
        fp = StringIO.StringIO("""
223
 
testfiles/select/1/1
224
 
- testfiles/select/1/2
225
 
+ testfiles/select/1/3
226
 
- testfiles/select/3""")
227
 
        sf = self.Select.filelist_get_sf(fp, 1, "test1")
228
 
        assert sf(self.makeext("1")) == 1
229
 
        assert sf(self.makeext("1/1")) == 1
230
 
        assert sf(self.makeext("1/1/2")) is None
231
 
        assert sf(self.makeext("1/2")) == 0
232
 
        assert sf(self.makeext("1/2/3")) == 0
233
 
        assert sf(self.makeext("1/3")) == 1
234
 
        assert sf(self.makeext("2")) is None
235
 
        assert sf(self.makeext("3")) == 0
236
 
 
237
 
    def testFilelistInclude3(self):
238
 
        """testFilelistInclude3 - with modifiers to check - works as expected"""
239
 
        fp = StringIO.StringIO("""
240
 
testfiles/select/1/1
241
 
- testfiles/select/1/2
242
 
+ testfiles/select/1/3
243
 
testfiles/select/1""")
244
 
        sf = self.Select.filelist_get_sf(fp, 1, "test1")
245
 
        assert sf(self.makeext("1")) == 1
246
 
        assert sf(self.makeext("1/1")) == 1
247
 
        assert sf(self.makeext("1/1/2")) is None
248
 
        assert sf(self.makeext("1/2")) == 0
249
 
        assert sf(self.makeext("1/2/3")) == 0
250
 
        assert sf(self.makeext("1/3")) == 1
251
 
        assert sf(self.makeext("2")) is None
252
 
        assert sf(self.makeext("3")) is None
253
 
 
254
 
#     def test_filelist_include_excluded_folder_with_included_contents(self):
255
 
#         """Check that excluded folder is included if subfolder is included at higher priority. """
256
 
#         # ToDo - currently fails. 1/2 should be included (scanned) because 1/2/1 is. Commandline --include/--exclude
257
 
#         # ToDo - and globbing filelists work this way
258
 
#         fp = StringIO.StringIO("""
259
 
# + testfiles/select/1/2/1
260
 
# - testfiles/select/1/2
261
 
# + testfiles/select/1/3
262
 
# testfiles/select/1""")
263
 
#         sf = self.Select.filelist_get_sf(fp, 1, "test1")
264
 
#         assert sf(self.makeext("1")) == 1
265
 
#         assert sf(self.makeext("1/1")) is None
266
 
#         assert sf(self.makeext("1/2/1")) == 1
267
 
#         assert sf(self.makeext("1/2")) == 0  # ToDo - what should this return?
268
 
#         assert sf(self.makeext("1/2/3")) == 0
269
 
#         assert sf(self.makeext("1/3")) == 1
270
 
#         assert sf(self.makeext("2")) is None
271
 
#         assert sf(self.makeext("3")) is None
272
 
 
273
 
    def testFilelistExclude2(self):
274
 
        """testFilelistExclude2 - with modifiers"""
275
 
        fp = StringIO.StringIO("""
276
 
testfiles/select/1/1
277
 
- testfiles/select/1/2
278
 
+ testfiles/select/1/3
279
 
- testfiles/select/3""")
280
 
        sf = self.Select.filelist_get_sf(fp, 0, "test1")
281
 
        sf_val1 = sf(self.root)
282
 
        assert sf_val1 == 1 or sf_val1 is None  # either is OK
283
 
        sf_val2 = sf(self.makeext("1"))
284
 
        assert sf_val2 == 1 or sf_val2 is None
285
 
        assert sf(self.makeext("1/1")) == 0
286
 
        assert sf(self.makeext("1/1/2")) == 0
287
 
        assert sf(self.makeext("1/2")) == 0
288
 
        assert sf(self.makeext("1/2/3")) == 0
289
 
        assert sf(self.makeext("1/3")) == 1
290
 
        assert sf(self.makeext("2")) is None
291
 
        assert sf(self.makeext("3")) == 0
292
 
 
293
 
    def test_filelist_exclude_2_with_trailing_white_space(self):
294
 
        """testFilelistExclude2 with modifiers - test trailing whitespace is ignored (1 and 2 spaces)"""
295
 
        fp = StringIO.StringIO("testfiles/select/1/1\n"
296
 
                               "- testfiles/select/1/2 \n"
297
 
                               "+ testfiles/select/1/3  \n"
298
 
                               "- testfiles/select/3")
299
 
        sf = self.Select.filelist_get_sf(fp, 0, "test1")
300
 
        sf_val1 = sf(self.root)
301
 
        assert sf_val1 == 1 or sf_val1 is None  # either is OK
302
 
        sf_val2 = sf(self.makeext("1"))
303
 
        assert sf_val2 == 1 or sf_val2 is None
304
 
        assert sf(self.makeext("1/1")) == 0
305
 
        assert sf(self.makeext("1/1/2")) == 0
306
 
        assert sf(self.makeext("1/2")) == 0
307
 
        assert sf(self.makeext("1/2/3")) == 0
308
 
        assert sf(self.makeext("1/3")) == 1
309
 
        assert sf(self.makeext("2")) is None
310
 
        assert sf(self.makeext("3")) == 0
311
 
 
312
 
    def test_filelist_exclude_with_single_quotes(self):
313
 
        """testFilelistExclude2 with modifiers - test unnecessary single quotes are ignored"""
314
 
        fp = StringIO.StringIO("testfiles/select/1/1\n"
315
 
                               "- testfiles/select/1/2\n"
316
 
                               "+ 'testfiles/select/1/3'\n"
317
 
                               "- testfiles/select/3")
318
 
        sf = self.Select.filelist_get_sf(fp, 0, "test1")
319
 
        sf_val1 = sf(self.root)
320
 
        assert sf_val1 == 1 or sf_val1 is None  # either is OK
321
 
        sf_val2 = sf(self.makeext("1"))
322
 
        assert sf_val2 == 1 or sf_val2 is None
323
 
        assert sf(self.makeext("1/1")) == 0
324
 
        assert sf(self.makeext("1/1/2")) == 0
325
 
        assert sf(self.makeext("1/2")) == 0
326
 
        assert sf(self.makeext("1/2/3")) == 0
327
 
        assert sf(self.makeext("1/3")) == 1
328
 
        assert sf(self.makeext("2")) is None
329
 
        assert sf(self.makeext("3")) == 0
330
 
 
331
 
    def test_filelist_exclude_with_full_line_comment(self):
332
 
        """testFilelistExclude2 with modifiers - test full-line comment is ignored"""
333
 
        fp = StringIO.StringIO("testfiles/select/1/1\n"
334
 
                               "- testfiles/select/1/2\n"
335
 
                               "# This is a full-line comment\n"
336
 
                               "+ testfiles/select/1/3\n"
337
 
                               "- testfiles/select/3")
338
 
        sf = self.Select.filelist_get_sf(fp, 0, "test1")
339
 
        sf_val1 = sf(self.root)
340
 
        assert sf_val1 == 1 or sf_val1 is None  # either is OK
341
 
        sf_val2 = sf(self.makeext("1"))
342
 
        assert sf_val2 == 1 or sf_val2 is None
343
 
        assert sf(self.makeext("1/1")) == 0
344
 
        assert sf(self.makeext("1/1/2")) == 0
345
 
        assert sf(self.makeext("1/2")) == 0
346
 
        assert sf(self.makeext("1/2/3")) == 0
347
 
        assert sf(self.makeext("1/3")) == 1
348
 
        assert sf(self.makeext("2")) is None
349
 
        assert sf(self.makeext("3")) == 0
350
 
 
351
 
    def test_filelist_exclude_with_blank_line(self):
352
 
        """testFilelistExclude2 with modifiers - test blank line is ignored"""
353
 
        fp = StringIO.StringIO("testfiles/select/1/1\n"
354
 
                               "- testfiles/select/1/2\n"
355
 
                               "\n"
356
 
                               "+ testfiles/select/1/3\n"
357
 
                               "- testfiles/select/3")
358
 
        sf = self.Select.filelist_get_sf(fp, 0, "test1")
359
 
        sf_val1 = sf(self.root)
360
 
        assert sf_val1 == 1 or sf_val1 is None  # either is OK
361
 
        sf_val2 = sf(self.makeext("1"))
362
 
        assert sf_val2 == 1 or sf_val2 is None
363
 
        assert sf(self.makeext("1/1")) == 0
364
 
        assert sf(self.makeext("1/1/2")) == 0
365
 
        assert sf(self.makeext("1/2")) == 0
366
 
        assert sf(self.makeext("1/2/3")) == 0
367
 
        assert sf(self.makeext("1/3")) == 1
368
 
        assert sf(self.makeext("2")) is None
369
 
        assert sf(self.makeext("3")) == 0
370
 
 
371
 
    def test_filelist_exclude_with_blank_line_and_whitespace(self):
372
 
        """testFilelistExclude2 with modifiers - test blank line with whitespace is ignored"""
373
 
        fp = StringIO.StringIO("testfiles/select/1/1\n"
374
 
                               "- testfiles/select/1/2\n"
375
 
                               " \n"
376
 
                               "+ testfiles/select/1/3\n"
377
 
                               "- testfiles/select/3")
378
 
        sf = self.Select.filelist_get_sf(fp, 0, "test1")
379
 
        sf_val1 = sf(self.root)
380
 
        assert sf_val1 == 1 or sf_val1 is None  # either is OK
381
 
        sf_val2 = sf(self.makeext("1"))
382
 
        assert sf_val2 == 1 or sf_val2 is None
383
 
        assert sf(self.makeext("1/1")) == 0
384
 
        assert sf(self.makeext("1/1/2")) == 0
385
 
        assert sf(self.makeext("1/2")) == 0
386
 
        assert sf(self.makeext("1/2/3")) == 0
387
 
        assert sf(self.makeext("1/3")) == 1
388
 
        assert sf(self.makeext("2")) is None
389
 
        assert sf(self.makeext("3")) == 0
390
 
 
391
 
    def test_filelist_exclude_with_double_quotes(self):
392
 
        """testFilelistExclude2 with modifiers - test unnecessary double quotes are ignored"""
393
 
        fp = StringIO.StringIO('testfiles/select/1/1\n'
394
 
                               '- testfiles/select/1/2\n'
395
 
                               '+ "testfiles/select/1/3"\n'
396
 
                               '- testfiles/select/3')
397
 
        sf = self.Select.filelist_get_sf(fp, 0, "test1")
398
 
        sf_val1 = sf(self.root)
399
 
        assert sf_val1 == 1 or sf_val1 is None  # either is OK
400
 
        sf_val2 = sf(self.makeext("1"))
401
 
        assert sf_val2 == 1 or sf_val2 is None
402
 
        assert sf(self.makeext("1/1")) == 0
403
 
        assert sf(self.makeext("1/1/2")) == 0
404
 
        assert sf(self.makeext("1/2")) == 0
405
 
        assert sf(self.makeext("1/2/3")) == 0
406
 
        assert sf(self.makeext("1/3")) == 1
407
 
        assert sf(self.makeext("2")) is None
408
 
        assert sf(self.makeext("3")) == 0
409
 
 
410
105
    def testGlobRE(self):
411
106
        """testGlobRE - test translation of shell pattern to regular exp"""
412
107
        assert self.Select.glob_to_re("hello") == "hello"
456
151
        assert select.glob_get_sf("**", 0)(root) == 0
457
152
        assert select.glob_get_sf("/foo/*", 0)(root) is None
458
153
 
459
 
        assert select.filelist_get_sf(StringIO.StringIO("/"), 1, "test")(root) == 1
460
 
        assert select.filelist_get_sf(StringIO.StringIO("/foo/bar"), 1, "test")(root) == 1
461
 
        assert select.filelist_get_sf(StringIO.StringIO("/"), 0, "test")(root) == 0
462
 
        assert select.filelist_get_sf(StringIO.StringIO("/foo/bar"), 0,
463
 
                                      "test")(root) is None
464
 
 
465
154
    def testOtherFilesystems(self):
466
155
        """Test to see if --exclude-other-filesystems works correctly"""
467
156
        root = Path("/")
531
220
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
532
221
                        ('1', '1', '3')])
533
222
 
534
 
    def test_globbing_filelist(self):
 
223
    def test_filelist(self):
535
224
        """Filelist glob test similar to above testParse2"""
536
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
225
        self.ParseTest([("--include-filelist", "file")],
537
226
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
538
227
                        ('1', '1', '3')],
539
228
                       ["- testfiles/select/1/1/1\n"
541
230
                        "- testfiles/select/1\n"
542
231
                        "- **"])
543
232
 
544
 
    def test_include_globbing_filelist_1_trailing_whitespace(self):
 
233
    def test_include_filelist_1_trailing_whitespace(self):
545
234
        """Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on include"""
546
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
235
        self.ParseTest([("--include-filelist", "file")],
547
236
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
548
237
                        ('1', '1', '3')],
549
238
                       ["- testfiles/select/1/1/1\n"
551
240
                        "- testfiles/select/1\n"
552
241
                        "- **"])
553
242
 
554
 
    def test_include_globbing_filelist_2_trailing_whitespaces(self):
 
243
    def test_include_filelist_2_trailing_whitespaces(self):
555
244
        """Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on include"""
556
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
245
        self.ParseTest([("--include-filelist", "file")],
557
246
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
558
247
                        ('1', '1', '3')],
559
248
                       ["- testfiles/select/1/1/1\n"
561
250
                        "- testfiles/select/1\n"
562
251
                        "- **"])
563
252
 
564
 
    def test_include_globbing_filelist_1_leading_whitespace(self):
 
253
    def test_include_filelist_1_leading_whitespace(self):
565
254
        """Filelist glob test similar to globbing filelist, but with 1 leading whitespace on include"""
566
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
255
        self.ParseTest([("--include-filelist", "file")],
567
256
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
568
257
                        ('1', '1', '3')],
569
258
                       ["- testfiles/select/1/1/1\n"
571
260
                        "- testfiles/select/1\n"
572
261
                        "- **"])
573
262
 
574
 
    def test_include_globbing_filelist_2_leading_whitespaces(self):
 
263
    def test_include_filelist_2_leading_whitespaces(self):
575
264
        """Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on include"""
576
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
265
        self.ParseTest([("--include-filelist", "file")],
577
266
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
578
267
                        ('1', '1', '3')],
579
268
                       ["- testfiles/select/1/1/1\n"
581
270
                        "- testfiles/select/1\n"
582
271
                        "- **"])
583
272
 
584
 
    def test_include_globbing_filelist_1_trailing_whitespace_exclude(self):
 
273
    def test_include_filelist_1_trailing_whitespace_exclude(self):
585
274
        """Filelist glob test similar to globbing filelist, but with 1 trailing whitespace on exclude"""
586
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
275
        self.ParseTest([("--include-filelist", "file")],
587
276
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
588
277
                        ('1', '1', '3')],
589
278
                       ["- testfiles/select/1/1/1 \n"
591
280
                        "- testfiles/select/1\n"
592
281
                        "- **"])
593
282
 
594
 
    def test_include_globbing_filelist_2_trailing_whitespace_exclude(self):
 
283
    def test_include_filelist_2_trailing_whitespace_exclude(self):
595
284
        """Filelist glob test similar to globbing filelist, but with 2 trailing whitespaces on exclude"""
596
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
285
        self.ParseTest([("--include-filelist", "file")],
597
286
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
598
287
                        ('1', '1', '3')],
599
288
                       ["- testfiles/select/1/1/1  \n"
601
290
                        "- testfiles/select/1\n"
602
291
                        "- **"])
603
292
 
604
 
    def test_include_globbing_filelist_1_leading_whitespace_exclude(self):
 
293
    def test_include_filelist_1_leading_whitespace_exclude(self):
605
294
        """Filelist glob test similar to globbing filelist, but with 1 leading whitespace on exclude"""
606
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
295
        self.ParseTest([("--include-filelist", "file")],
607
296
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
608
297
                        ('1', '1', '3')],
609
298
                       [" - testfiles/select/1/1/1\n"
611
300
                        "- testfiles/select/1\n"
612
301
                        "- **"])
613
302
 
614
 
    def test_include_globbing_filelist_2_leading_whitespaces_exclude(self):
 
303
    def test_include_filelist_2_leading_whitespaces_exclude(self):
615
304
        """Filelist glob test similar to globbing filelist, but with 2 leading whitespaces on exclude"""
616
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
305
        self.ParseTest([("--include-filelist", "file")],
617
306
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
618
307
                        ('1', '1', '3')],
619
308
                       ["  - testfiles/select/1/1/1\n"
621
310
                        "- testfiles/select/1\n"
622
311
                        "- **"])
623
312
 
624
 
    def test_include_globbing_filelist_check_excluded_folder_included_for_contents(self):
 
313
    def test_include_filelist_check_excluded_folder_included_for_contents(self):
625
314
        """Filelist glob test to check excluded folder is included if contents are"""
626
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
315
        self.ParseTest([("--include-filelist", "file")],
627
316
                       [(), ('1',), ('1', '1'), ('1', '1', '1'), ('1', '1', '2'),
628
317
                        ('1', '1', '3'), ('1', '2'), ('1', '2', '1'), ('1', '3'), ('1', '3', '1'), ('1', '3', '2'),
629
318
                        ('1', '3', '3')],
632
321
                        "testfiles/select/1\n"
633
322
                        "- **"])
634
323
 
635
 
    def test_include_globbing_filelist_with_unnecessary_quotes(self):
 
324
    def test_include_filelist_with_unnecessary_quotes(self):
636
325
        """Filelist glob test similar to globbing filelist, but with quotes around one of the paths."""
637
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
326
        self.ParseTest([("--include-filelist", "file")],
638
327
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
639
328
                        ('1', '1', '3')],
640
329
                       ["- 'testfiles/select/1/1/1'\n"
642
331
                        "- testfiles/select/1\n"
643
332
                        "- **"])
644
333
 
645
 
    def test_include_globbing_filelist_with_unnecessary_double_quotes(self):
 
334
    def test_include_filelist_with_unnecessary_double_quotes(self):
646
335
        """Filelist glob test similar to globbing filelist, but with double quotes around one of the paths."""
647
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
336
        self.ParseTest([("--include-filelist", "file")],
648
337
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
649
338
                        ('1', '1', '3')],
650
339
                       ['- "testfiles/select/1/1/1"\n'
652
341
                        '- testfiles/select/1\n'
653
342
                        '- **'])
654
343
 
655
 
    def test_include_globbing_filelist_with_full_line_comment(self):
 
344
    def test_include_filelist_with_full_line_comment(self):
656
345
        """Filelist glob test similar to globbing filelist, but with a full-line comment."""
657
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
346
        self.ParseTest([("--include-filelist", "file")],
658
347
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
659
348
                        ('1', '1', '3')],
660
349
                       ['- testfiles/select/1/1/1\n'
663
352
                        '- testfiles/select/1\n'
664
353
                        '- **'])
665
354
 
666
 
    def test_include_globbing_filelist_with_blank_line(self):
 
355
    def test_include_filelist_with_blank_line(self):
667
356
        """Filelist glob test similar to globbing filelist, but with a blank line."""
668
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
357
        self.ParseTest([("--include-filelist", "file")],
669
358
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
670
359
                        ('1', '1', '3')],
671
360
                       ['- testfiles/select/1/1/1\n'
674
363
                        '- testfiles/select/1\n'
675
364
                        '- **'])
676
365
 
677
 
    def test_include_globbing_filelist_with_blank_line_and_whitespace(self):
 
366
    def test_include_filelist_with_blank_line_and_whitespace(self):
678
367
        """Filelist glob test similar to globbing filelist, but with a blank line and whitespace."""
679
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
368
        self.ParseTest([("--include-filelist", "file")],
680
369
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
681
370
                        ('1', '1', '3')],
682
371
                       ['- testfiles/select/1/1/1\n'
685
374
                        '- testfiles/select/1\n'
686
375
                        '- **'])
687
376
 
688
 
    def test_include_globbing_filelist_asterisk(self):
 
377
    def test_include_filelist_asterisk(self):
689
378
        """Filelist glob test with * instead of 'testfiles'"""
690
379
        # Thank you to Elifarley Cruz for this test case
691
380
        # (https://bugs.launchpad.net/duplicity/+bug/884371).
692
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
381
        self.ParseTest([("--include-filelist", "file")],
693
382
                       [(), ('1',), ('1', '1'), ('1', '1', '1'),
694
383
                        ('1', '1', '2'), ('1', '1', '3')],
695
384
                       ["*/select/1/1\n"
696
385
                        "- **"])
697
386
 
698
 
    def test_include_globbing_filelist_asterisk_2(self):
699
 
        """Identical to test_globbing_filelist, but with the exclude 'select' replaced with '*'"""
700
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
387
    def test_include_filelist_asterisk_2(self):
 
388
        """Identical to test_filelist, but with the exclude 'select' replaced with '*'"""
 
389
        self.ParseTest([("--include-filelist", "file")],
701
390
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
702
391
                        ('1', '1', '3')],
703
392
                       ["- testfiles/*/1/1/1\n"
706
395
                        "- **"])
707
396
 
708
397
    @unittest.expectedFailure
709
 
    def test_include_globbing_filelist_asterisk_3(self):
710
 
        """Identical to test_globbing_filelist, but with the auto-include 'select' replaced with '*'"""
 
398
    def test_include_filelist_asterisk_3(self):
 
399
        """Identical to test_filelist, but with the auto-include 'select' replaced with '*'"""
711
400
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
712
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
401
        self.ParseTest([("--include-filelist", "file")],
713
402
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
714
403
                        ('1', '1', '3')],
715
404
                       ["- testfiles/select/1/1/1\n"
718
407
                        "- **"])
719
408
 
720
409
    @unittest.expectedFailure
721
 
    def test_include_globbing_filelist_asterisk_4(self):
722
 
        """Identical to test_globbing_filelist, but with a specific include 'select' replaced with '*'"""
 
410
    def test_include_filelist_asterisk_4(self):
 
411
        """Identical to test_filelist, but with a specific include 'select' replaced with '*'"""
723
412
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
724
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
413
        self.ParseTest([("--include-filelist", "file")],
725
414
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
726
415
                        ('1', '1', '3')],
727
416
                       ["- testfiles/select/1/1/1\n"
730
419
                        "- **"])
731
420
 
732
421
    @unittest.expectedFailure
733
 
    def test_include_globbing_filelist_asterisk_5(self):
734
 
        """Identical to test_globbing_filelist, but with all 'select's replaced with '*'"""
 
422
    def test_include_filelist_asterisk_5(self):
 
423
        """Identical to test_filelist, but with all 'select's replaced with '*'"""
735
424
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
736
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
425
        self.ParseTest([("--include-filelist", "file")],
737
426
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
738
427
                        ('1', '1', '3')],
739
428
                       ["- testfiles/*/1/1/1\n"
741
430
                        "- testfiles/*/1\n"
742
431
                        "- **"])
743
432
 
744
 
    def test_include_globbing_filelist_asterisk_6(self):
745
 
        """Identical to test_globbing_filelist, but with numerous excluded folders replaced with '*'"""
746
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
433
    def test_include_filelist_asterisk_6(self):
 
434
        """Identical to test_filelist, but with numerous excluded folders replaced with '*'"""
 
435
        self.ParseTest([("--include-filelist", "file")],
747
436
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
748
437
                        ('1', '1', '3')],
749
438
                       ["- */*/1/1/1\n"
752
441
                        "- **"])
753
442
 
754
443
    @unittest.expectedFailure
755
 
    def test_include_globbing_filelist_asterisk_7(self):
756
 
        """Identical to test_globbing_filelist, but with numerous included/excluded folders replaced with '*'"""
 
444
    def test_include_filelist_asterisk_7(self):
 
445
        """Identical to test_filelist, but with numerous included/excluded folders replaced with '*'"""
757
446
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
758
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
447
        self.ParseTest([("--include-filelist", "file")],
759
448
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
760
449
                        ('1', '1', '3')],
761
450
                       ["- */*/1/1/1\n"
763
452
                        "- */*/1\n"
764
453
                        "- **"])
765
454
 
766
 
    def test_include_globbing_filelist_double_asterisk_1(self):
767
 
        """Identical to test_globbing_filelist, but with the exclude 'select' replaced with '**'"""
768
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
455
    def test_include_filelist_double_asterisk_1(self):
 
456
        """Identical to test_filelist, but with the exclude 'select' replaced with '**'"""
 
457
        self.ParseTest([("--include-filelist", "file")],
769
458
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
770
459
                        ('1', '1', '3')],
771
460
                       ["- testfiles/**/1/1/1\n"
774
463
                        "- **"])
775
464
 
776
465
    @unittest.expectedFailure
777
 
    def test_include_globbing_filelist_double_asterisk_2(self):
778
 
        """Identical to test_globbing_filelist, but with the include 'select' replaced with '**'"""
 
466
    def test_include_filelist_double_asterisk_2(self):
 
467
        """Identical to test_filelist, but with the include 'select' replaced with '**'"""
779
468
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
780
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
469
        self.ParseTest([("--include-filelist", "file")],
781
470
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
782
471
                        ('1', '1', '3')],
783
472
                       ["- testfiles/select/1/1/1\n"
785
474
                        "- testfiles/select/1\n"
786
475
                        "- **"])
787
476
 
788
 
    def test_include_globbing_filelist_double_asterisk_3(self):
789
 
        """Identical to test_globbing_filelist, but with the exclude 'testfiles/select' replaced with '**'"""
790
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
477
    def test_include_filelist_double_asterisk_3(self):
 
478
        """Identical to test_filelist, but with the exclude 'testfiles/select' replaced with '**'"""
 
479
        self.ParseTest([("--include-filelist", "file")],
791
480
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
792
481
                        ('1', '1', '3')],
793
482
                       ["- **/1/1/1\n"
796
485
                        "- **"])
797
486
 
798
487
    @unittest.expectedFailure
799
 
    def test_include_globbing_filelist_double_asterisk_4(self):
800
 
        """Identical to test_globbing_filelist, but with the include 'testfiles/select' replaced with '**'"""
 
488
    def test_include_filelist_double_asterisk_4(self):
 
489
        """Identical to test_filelist, but with the include 'testfiles/select' replaced with '**'"""
801
490
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
802
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
491
        self.ParseTest([("--include-filelist", "file")],
803
492
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
804
493
                        ('1', '1', '3')],
805
494
                       ["- testfiles/select/1/1/1\n"
808
497
                        "- **"])
809
498
 
810
499
    @unittest.expectedFailure
811
 
    def test_include_globbing_filelist_double_asterisk_5(self):
812
 
        """Identical to test_globbing_filelist, but with all 'testfiles/select's replaced with '**'"""
 
500
    def test_include_filelist_double_asterisk_5(self):
 
501
        """Identical to test_filelist, but with all 'testfiles/select's replaced with '**'"""
813
502
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
814
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
503
        self.ParseTest([("--include-filelist", "file")],
815
504
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
816
505
                        ('1', '1', '3')],
817
506
                       ["- **/1/1/1\n"
819
508
                        "- **/1\n"
820
509
                        "- **"])
821
510
 
822
 
    def test_include_globbing_filelist_trailing_slashes(self):
 
511
    def test_include_filelist_trailing_slashes(self):
823
512
        """Filelist glob test similar to globbing filelist, but with trailing slashes"""
824
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
513
        self.ParseTest([("--include-filelist", "file")],
825
514
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
826
515
                        ('1', '1', '3')],
827
516
                       ["- testfiles/select/1/1/1/\n"
830
519
                        "- **"])
831
520
 
832
521
    @unittest.expectedFailure
833
 
    def test_include_globbing_filelist_trailing_slashes_and_single_asterisks(self):
 
522
    def test_include_filelist_trailing_slashes_and_single_asterisks(self):
834
523
        """Filelist glob test similar to globbing filelist, but with trailing slashes and single asterisks"""
835
524
        # Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
836
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
525
        self.ParseTest([("--include-filelist", "file")],
837
526
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
838
527
                        ('1', '1', '3')],
839
528
                       ["- */select/1/1/1/\n"
842
531
                        "- **"])
843
532
 
844
533
    @unittest.expectedFailure
845
 
    def test_include_globbing_filelist_trailing_slashes_and_double_asterisks(self):
 
534
    def test_include_filelist_trailing_slashes_and_double_asterisks(self):
846
535
        """Filelist glob test similar to globbing filelist, but with trailing slashes and double asterisks"""
847
536
        # Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
848
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
537
        self.ParseTest([("--include-filelist", "file")],
849
538
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
850
539
                        ('1', '1', '3')],
851
540
                       ["- **/1/1/1/\n"
853
542
                        "- **/1/\n"
854
543
                        "- **"])
855
544
 
856
 
    def test_exclude_globbing_filelist(self):
857
 
        """Exclude version of test_globbing_filelist"""
858
 
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
545
 
 
546
    def test_filelist_null_separator(self):
 
547
        """test_filelist, but with null_separator set"""
 
548
        self.set_global('null_separator', 1)
 
549
        self.ParseTest([("--include-filelist", "file")],
 
550
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
 
551
                        ('1', '1', '3')],
 
552
                       ["\0- testfiles/select/1/1/1\0testfiles/select/1/1\0- testfiles/select/1\0- **\0"])
 
553
 
 
554
    def test_exclude_filelist(self):
 
555
        """Exclude version of test_filelist"""
 
556
        self.ParseTest([("--exclude-filelist", "file")],
859
557
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
860
558
                        ('1', '1', '3')],
861
559
                       ["testfiles/select/1/1/1\n"
863
561
                        "testfiles/select/1\n"
864
562
                        "- **"])
865
563
 
866
 
    def test_exclude_globbing_filelist_asterisk_1(self):
867
 
        """Exclude version of test_include_globbing_filelist_asterisk"""
868
 
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
564
    def test_exclude_filelist_asterisk_1(self):
 
565
        """Exclude version of test_include_filelist_asterisk"""
 
566
        self.ParseTest([("--exclude-filelist", "file")],
869
567
                       [(), ('1',), ('1', '1'), ('1', '1', '1'),
870
568
                        ('1', '1', '2'), ('1', '1', '3')],
871
569
                       ["+ */select/1/1\n"
872
570
                        "- **"])
873
571
 
874
 
    def test_exclude_globbing_filelist_asterisk_2(self):
875
 
        """Identical to test_exclude_globbing_filelist, but with the exclude 'select' replaced with '*'"""
876
 
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
572
    def test_exclude_filelist_asterisk_2(self):
 
573
        """Identical to test_exclude_filelist, but with the exclude 'select' replaced with '*'"""
 
574
        self.ParseTest([("--exclude-filelist", "file")],
877
575
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
878
576
                        ('1', '1', '3')],
879
577
                       ["testfiles/*/1/1/1\n"
882
580
                        "- **"])
883
581
 
884
582
    @unittest.expectedFailure
885
 
    def test_exclude_globbing_filelist_asterisk_3(self):
886
 
        """Identical to test_exclude_globbing_filelist, but with the include 'select' replaced with '*'"""
 
583
    def test_exclude_filelist_asterisk_3(self):
 
584
        """Identical to test_exclude_filelist, but with the include 'select' replaced with '*'"""
887
585
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
888
 
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
586
        self.ParseTest([("--exclude-filelist", "file")],
889
587
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
890
588
                        ('1', '1', '3')],
891
589
                       ["testfiles/select/1/1/1\n"
893
591
                        "testfiles/select/1\n"
894
592
                        "- **"])
895
593
 
896
 
    def test_exclude_globbing_filelist_asterisk_4(self):
897
 
        """Identical to test_exclude_globbing_filelist, but with numerous excluded folders replaced with '*'"""
898
 
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
594
    def test_exclude_filelist_asterisk_4(self):
 
595
        """Identical to test_exclude_filelist, but with numerous excluded folders replaced with '*'"""
 
596
        self.ParseTest([("--exclude-filelist", "file")],
899
597
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
900
598
                        ('1', '1', '3')],
901
599
                       ["*/select/1/1/1\n"
904
602
                        "- **"])
905
603
 
906
604
    @unittest.expectedFailure
907
 
    def test_exclude_globbing_filelist_asterisk_5(self):
908
 
        """Identical to test_exclude_globbing_filelist, but with numerous included/excluded folders replaced with '*'"""
 
605
    def test_exclude_filelist_asterisk_5(self):
 
606
        """Identical to test_exclude_filelist, but with numerous included/excluded folders replaced with '*'"""
909
607
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
910
 
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
608
        self.ParseTest([("--exclude-filelist", "file")],
911
609
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
912
610
                        ('1', '1', '3')],
913
611
                       ["*/select/1/1/1\n"
916
614
                        "- **"])
917
615
 
918
616
    @unittest.expectedFailure
919
 
    def test_exclude_globbing_filelist_double_asterisk(self):
920
 
        """Identical to test_exclude_globbing_filelist, but with all included/excluded folders replaced with '**'"""
 
617
    def test_exclude_filelist_double_asterisk(self):
 
618
        """Identical to test_exclude_filelist, but with all included/excluded folders replaced with '**'"""
921
619
        # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
922
 
        self.ParseTest([("--exclude-globbing-filelist", "file")],
 
620
        self.ParseTest([("--exclude-filelist", "file")],
923
621
                       [(), ('1',), ('1', '1'), ('1', '1', '2'),
924
622
                        ('1', '1', '3')],
925
623
                       ["**/1/1/1\n"
956
654
                        ('3', '3'),
957
655
                        ('3', '3', '2')])
958
656
 
959
 
    def test_globbing_filelist2(self):
 
657
    def test_filelist2(self):
960
658
        """Filelist glob test similar to above testGlob"""
961
 
        self.ParseTest([("--exclude-globbing-filelist", "asoeuth")],
 
659
        self.ParseTest([("--exclude-filelist", "asoeuth")],
962
660
                       [(), ('1',), ('1', '1'),
963
661
                        ('1', '1', '1'), ('1', '1', '2'),
964
662
                        ('1', '2'), ('1', '2', '1'), ('1', '2', '2')],
967
665
+ testfiles/select/1
968
666
**
969
667
"""])
970
 
        self.ParseTest([("--include-globbing-filelist", "file")],
 
668
        self.ParseTest([("--include-filelist", "file")],
971
669
                       [(), ('1',), ('1', '1'),
972
670
                        ('1', '1', '2'),
973
671
                        ('1', '2'),