Merge lp:~aaron-whitehouse/duplicity/bug_884371_asterisks_in_includes into lp:~duplicity-team/duplicity/0.7-series

Proposed by Aaron Whitehouse
Status: Merged
Merged at revision: 1066
Proposed branch: lp:~aaron-whitehouse/duplicity/bug_884371_asterisks_in_includes
Merge into: lp:~duplicity-team/duplicity/0.7-series
Diff against target: 324 lines (+297/-0)
2 files modified
testing/functional/test_selection.py (+88/-0)
testing/unit/test_selection.py (+209/-0)
To merge this branch: bzr merge lp:~aaron-whitehouse/duplicity/bug_884371_asterisks_in_includes
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+248065@code.launchpad.net

Description of the change

Added tests to unit/test_selection.py and funtional/test_selection.py to show the behaviour reported in Bug #884371, i.e. that selection is incorrect when there is a * or ** on an include line of a filelist or commandline --include.

To post a comment you must log in.
Revision history for this message
Aaron Whitehouse (aaron-whitehouse) wrote :

You may have noticed that I've been adding test cases to trunk for some of the filelist-related bugs in the tracker. In addition to helping people fix the bugs, this is so that, if I get a chance to work on tidying up the selection code, I will know if I've fixed any of the bugs as a consequence.

1068. By Aaron Whitehouse <email address hidden>

Added credit to Elifarley Cruz for one of the test cases.

Revision history for this message
Kenneth Loafman (kenneth-loafman) wrote :

> You may have noticed that I've been adding test cases to trunk for some of the
> filelist-related bugs in the tracker. In addition to helping people fix the
> bugs, this is so that, if I get a chance to work on tidying up the selection
> code, I will know if I've fixed any of the bugs as a consequence.

I really appreciate the tests and the thoroughness of the tests. Keep it up!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'testing/functional/test_selection.py'
2--- testing/functional/test_selection.py 2015-01-29 13:34:43 +0000
3+++ testing/functional/test_selection.py 2015-01-29 23:17:01 +0000
4@@ -582,6 +582,7 @@
5 restored = self.directory_tree_to_list_of_lists(restore_dir)
6 self.assertEqual(restored, self.expected_restored_tree)
7
8+
9 class TestIncludeExcludedForContents(IncludeExcludeFunctionalTest):
10 """ Test to check that folders that are excluded are included if they contain includes of higher priority.
11 Exhibits the issue reported in Bug #1408411 (https://bugs.launchpad.net/duplicity/+bug/1408411). """
12@@ -639,5 +640,92 @@
13 self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/exclude.txt"])
14 self.restore_and_check()
15
16+
17+class TestAsterisks(IncludeExcludeFunctionalTest):
18+ """ Test to check that asterisks work as expected
19+ Exhibits the issue reported in Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371).
20+ See the unit tests for more granularity on the issue."""
21+
22+ def restore_and_check(self):
23+ """Restores the backup and compares to what is expected."""
24+ self.restore()
25+ restore_dir = 'testfiles/restore_out'
26+ restored = self.directory_tree_to_list_of_lists(restore_dir)
27+ self.assertEqual(restored, [['2'], ['1']])
28+
29+ def test_exclude_globbing_filelist_asterisks_none(self):
30+ """Basic exclude globbing filelist."""
31+ with open("testfiles/filelist.txt", 'w') as f:
32+ f.write("+ testfiles/select/1/2/1\n"
33+ "- testfiles/select/1/2\n"
34+ "- testfiles/select/1/1\n"
35+ "- testfiles/select/1/3")
36+ self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
37+ self.restore_and_check()
38+
39+ @unittest.expectedFailure
40+ def test_exclude_globbing_filelist_asterisks_single(self):
41+ """Exclude globbing filelist with asterisks replacing folders."""
42+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
43+ with open("testfiles/filelist.txt", 'w') as f:
44+ f.write("+ */select/1/2/1\n"
45+ "- */select/1/2\n"
46+ "- testfiles/*/1/1\n"
47+ "- */*/1/3")
48+ self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
49+ self.restore_and_check()
50+
51+ @unittest.expectedFailure
52+ def test_exclude_globbing_filelist_asterisks_double_asterisks(self):
53+ """Exclude globbing filelist with double asterisks replacing folders."""
54+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
55+ with open("testfiles/filelist.txt", 'w') as f:
56+ f.write("+ **/1/2/1\n"
57+ "- **/1/2\n"
58+ "- **/select/1/1\n"
59+ "- testfiles/select/1/3")
60+ self.backup("full", "testfiles/select/1", options=["--exclude-globbing-filelist=testfiles/filelist.txt"])
61+ self.restore_and_check()
62+
63+ def test_commandline_asterisks_single_excludes_only(self):
64+ """test_commandline_include_exclude with single asterisks on exclude lines."""
65+ self.backup("full", "testfiles/select/1",
66+ options=["--include", "testfiles/select/1/2/1",
67+ "--exclude", "testfiles/*/1/2",
68+ "--exclude", "*/select/1/1",
69+ "--exclude", "*/select/1/3"])
70+ self.restore_and_check()
71+
72+ @unittest.expectedFailure
73+ def test_commandline_asterisks_single_both(self):
74+ """test_commandline_include_exclude with single asterisks on both exclude and include lines."""
75+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
76+ self.backup("full", "testfiles/select/1",
77+ options=["--include", "*/select/1/2/1",
78+ "--exclude", "testfiles/*/1/2",
79+ "--exclude", "*/select/1/1",
80+ "--exclude", "*/select/1/3"])
81+ self.restore_and_check()
82+
83+ def test_commandline_asterisks_double_exclude_only(self):
84+ """test_commandline_include_exclude with double asterisks on exclude lines."""
85+ self.backup("full", "testfiles/select/1",
86+ options=["--include", "testfiles/select/1/2/1",
87+ "--exclude", "**/1/2",
88+ "--exclude", "**/1/1",
89+ "--exclude", "**/1/3"])
90+ self.restore_and_check()
91+
92+ @unittest.expectedFailure
93+ def test_commandline_asterisks_double_both(self):
94+ """test_commandline_include_exclude with double asterisks on both exclude and include lines."""
95+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
96+ self.backup("full", "testfiles/select/1",
97+ options=["--include", "**/1/2/1",
98+ "--exclude", "**/1/2",
99+ "--exclude", "**/1/1",
100+ "--exclude", "**/1/3"])
101+ self.restore_and_check()
102+
103 if __name__ == "__main__":
104 unittest.main()
105
106=== modified file 'testing/unit/test_selection.py'
107--- testing/unit/test_selection.py 2015-01-22 23:38:29 +0000
108+++ testing/unit/test_selection.py 2015-01-29 23:17:01 +0000
109@@ -682,6 +682,215 @@
110 '- testfiles/select/1\n'
111 '- **'])
112
113+ def test_include_globbing_filelist_asterisk(self):
114+ """Filelist glob test with * instead of 'testfiles'"""
115+ # Thank you to Elifarley Cruz for this test case
116+ # (https://bugs.launchpad.net/duplicity/+bug/884371).
117+ self.ParseTest([("--include-globbing-filelist", "file")],
118+ [(), ('1',), ('1', '1'), ('1', '1', '1'),
119+ ('1', '1', '2'), ('1', '1', '3')],
120+ ["*/select/1/1\n"
121+ "- **"])
122+
123+ def test_include_globbing_filelist_asterisk_2(self):
124+ """Identical to test_globbing_filelist, but with the exclude 'select' replaced with '*'"""
125+ self.ParseTest([("--include-globbing-filelist", "file")],
126+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
127+ ('1', '1', '3')],
128+ ["- testfiles/*/1/1/1\n"
129+ "testfiles/select/1/1\n"
130+ "- testfiles/select/1\n"
131+ "- **"])
132+
133+ @unittest.expectedFailure
134+ def test_include_globbing_filelist_asterisk_3(self):
135+ """Identical to test_globbing_filelist, but with the auto-include 'select' replaced with '*'"""
136+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
137+ self.ParseTest([("--include-globbing-filelist", "file")],
138+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
139+ ('1', '1', '3')],
140+ ["- testfiles/select/1/1/1\n"
141+ "testfiles/*/1/1\n"
142+ "- testfiles/select/1\n"
143+ "- **"])
144+
145+ @unittest.expectedFailure
146+ def test_include_globbing_filelist_asterisk_4(self):
147+ """Identical to test_globbing_filelist, but with a specific include 'select' replaced with '*'"""
148+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
149+ self.ParseTest([("--include-globbing-filelist", "file")],
150+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
151+ ('1', '1', '3')],
152+ ["- testfiles/select/1/1/1\n"
153+ "+ testfiles/*/1/1\n"
154+ "- testfiles/select/1\n"
155+ "- **"])
156+
157+ @unittest.expectedFailure
158+ def test_include_globbing_filelist_asterisk_5(self):
159+ """Identical to test_globbing_filelist, but with all 'select's replaced with '*'"""
160+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
161+ self.ParseTest([("--include-globbing-filelist", "file")],
162+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
163+ ('1', '1', '3')],
164+ ["- testfiles/*/1/1/1\n"
165+ "+ testfiles/*/1/1\n"
166+ "- testfiles/*/1\n"
167+ "- **"])
168+
169+ def test_include_globbing_filelist_asterisk_6(self):
170+ """Identical to test_globbing_filelist, but with numerous excluded folders replaced with '*'"""
171+ self.ParseTest([("--include-globbing-filelist", "file")],
172+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
173+ ('1', '1', '3')],
174+ ["- */*/1/1/1\n"
175+ "+ testfiles/select/1/1\n"
176+ "- */*/1\n"
177+ "- **"])
178+
179+ @unittest.expectedFailure
180+ def test_include_globbing_filelist_asterisk_7(self):
181+ """Identical to test_globbing_filelist, but with numerous included/excluded folders replaced with '*'"""
182+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
183+ self.ParseTest([("--include-globbing-filelist", "file")],
184+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
185+ ('1', '1', '3')],
186+ ["- */*/1/1/1\n"
187+ "+ */*/1/1\n"
188+ "- */*/1\n"
189+ "- **"])
190+
191+
192+ def test_include_globbing_filelist_double_asterisk_1(self):
193+ """Identical to test_globbing_filelist, but with the exclude 'select' replaced with '**'"""
194+ self.ParseTest([("--include-globbing-filelist", "file")],
195+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
196+ ('1', '1', '3')],
197+ ["- testfiles/**/1/1/1\n"
198+ "testfiles/select/1/1\n"
199+ "- testfiles/select/1\n"
200+ "- **"])
201+
202+ @unittest.expectedFailure
203+ def test_include_globbing_filelist_double_asterisk_2(self):
204+ """Identical to test_globbing_filelist, but with the include 'select' replaced with '**'"""
205+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
206+ self.ParseTest([("--include-globbing-filelist", "file")],
207+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
208+ ('1', '1', '3')],
209+ ["- testfiles/select/1/1/1\n"
210+ "testfiles/**/1/1\n"
211+ "- testfiles/select/1\n"
212+ "- **"])
213+
214+ def test_include_globbing_filelist_double_asterisk_3(self):
215+ """Identical to test_globbing_filelist, but with the exclude 'testfiles/select' replaced with '**'"""
216+ self.ParseTest([("--include-globbing-filelist", "file")],
217+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
218+ ('1', '1', '3')],
219+ ["- **/1/1/1\n"
220+ "testfiles/select/1/1\n"
221+ "- testfiles/select/1\n"
222+ "- **"])
223+
224+ @unittest.expectedFailure
225+ def test_include_globbing_filelist_double_asterisk_4(self):
226+ """Identical to test_globbing_filelist, but with the include 'testfiles/select' replaced with '**'"""
227+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
228+ self.ParseTest([("--include-globbing-filelist", "file")],
229+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
230+ ('1', '1', '3')],
231+ ["- testfiles/select/1/1/1\n"
232+ "**/1/1\n"
233+ "- testfiles/select/1\n"
234+ "- **"])
235+
236+ @unittest.expectedFailure
237+ def test_include_globbing_filelist_double_asterisk_5(self):
238+ """Identical to test_globbing_filelist, but with all 'testfiles/select's replaced with '**'"""
239+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
240+ self.ParseTest([("--include-globbing-filelist", "file")],
241+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
242+ ('1', '1', '3')],
243+ ["- **/1/1/1\n"
244+ "**/1/1\n"
245+ "- **/1\n"
246+ "- **"])
247+
248+ def test_exclude_globbing_filelist(self):
249+ """Exclude version of test_globbing_filelist"""
250+ self.ParseTest([("--exclude-globbing-filelist", "file")],
251+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
252+ ('1', '1', '3')],
253+ ["testfiles/select/1/1/1\n"
254+ "+ testfiles/select/1/1\n"
255+ "testfiles/select/1\n"
256+ "- **"])
257+
258+ def test_exclude_globbing_filelist_asterisk_1(self):
259+ """Exclude version of test_include_globbing_filelist_asterisk"""
260+ self.ParseTest([("--exclude-globbing-filelist", "file")],
261+ [(), ('1',), ('1', '1'), ('1', '1', '1'),
262+ ('1', '1', '2'), ('1', '1', '3')],
263+ ["+ */select/1/1\n"
264+ "- **"])
265+
266+ def test_exclude_globbing_filelist_asterisk_2(self):
267+ """Identical to test_exclude_globbing_filelist, but with the exclude 'select' replaced with '*'"""
268+ self.ParseTest([("--exclude-globbing-filelist", "file")],
269+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
270+ ('1', '1', '3')],
271+ ["testfiles/*/1/1/1\n"
272+ "+ testfiles/select/1/1\n"
273+ "testfiles/select/1\n"
274+ "- **"])
275+
276+ @unittest.expectedFailure
277+ def test_exclude_globbing_filelist_asterisk_3(self):
278+ """Identical to test_exclude_globbing_filelist, but with the include 'select' replaced with '*'"""
279+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
280+ self.ParseTest([("--exclude-globbing-filelist", "file")],
281+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
282+ ('1', '1', '3')],
283+ ["testfiles/select/1/1/1\n"
284+ "+ testfiles/*/1/1\n"
285+ "testfiles/select/1\n"
286+ "- **"])
287+
288+ def test_exclude_globbing_filelist_asterisk_4(self):
289+ """Identical to test_exclude_globbing_filelist, but with numerous excluded folders replaced with '*'"""
290+ self.ParseTest([("--exclude-globbing-filelist", "file")],
291+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
292+ ('1', '1', '3')],
293+ ["*/select/1/1/1\n"
294+ "+ testfiles/select/1/1\n"
295+ "*/*/1\n"
296+ "- **"])
297+
298+ @unittest.expectedFailure
299+ def test_exclude_globbing_filelist_asterisk_5(self):
300+ """Identical to test_exclude_globbing_filelist, but with numerous included/excluded folders replaced with '*'"""
301+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
302+ self.ParseTest([("--exclude-globbing-filelist", "file")],
303+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
304+ ('1', '1', '3')],
305+ ["*/select/1/1/1\n"
306+ "+ */*/1/1\n"
307+ "*/*/1\n"
308+ "- **"])
309+
310+ @unittest.expectedFailure
311+ def test_exclude_globbing_filelist_double_asterisk(self):
312+ """Identical to test_exclude_globbing_filelist, but with all included/excluded folders replaced with '**'"""
313+ # Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
314+ self.ParseTest([("--exclude-globbing-filelist", "file")],
315+ [(), ('1',), ('1', '1'), ('1', '1', '2'),
316+ ('1', '1', '3')],
317+ ["**/1/1/1\n"
318+ "+ **/1/1\n"
319+ "**/1\n"
320+ "- **"])
321+
322 def testGlob(self):
323 """Test globbing expression"""
324 self.ParseTest([("--exclude", "**[3-5]"),

Subscribers

People subscribed via source and target branches