674
676
self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"])
675
677
self.restore_and_check()
677
@unittest.expectedFailure
678
679
def test_exclude_filelist_asterisks_single(self):
679
680
"""Exclude filelist with asterisks replacing folders."""
680
# Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
681
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
681
682
with open("testfiles/filelist.txt", 'w') as f:
682
683
f.write("+ */select/1/2/1\n"
683
684
"- */select/1/2\n"
686
687
self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"])
687
688
self.restore_and_check()
689
@unittest.expectedFailure
690
690
def test_exclude_filelist_asterisks_double_asterisks(self):
691
691
"""Exclude filelist with double asterisks replacing folders."""
692
# Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
692
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
693
693
with open("testfiles/filelist.txt", 'w') as f:
694
694
f.write("+ **/1/2/1\n"
707
707
"--exclude", "*/select/1/3"])
708
708
self.restore_and_check()
710
@unittest.expectedFailure
711
710
def test_commandline_asterisks_single_both(self):
712
711
"""test_commandline_include_exclude with single asterisks on both exclude and include lines."""
713
# Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
712
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
714
713
self.backup("full", "testfiles/select/1",
715
714
options=["--include", "*/select/1/2/1",
716
715
"--exclude", "testfiles/*/1/2",
727
726
"--exclude", "**/1/3"])
728
727
self.restore_and_check()
730
@unittest.expectedFailure
731
729
def test_commandline_asterisks_double_both(self):
732
730
"""test_commandline_include_exclude with double asterisks on both exclude and include lines."""
733
# Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
731
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
734
732
self.backup("full", "testfiles/select/1",
735
733
options=["--include", "**/1/2/1",
736
734
"--exclude", "**/1/2",
738
736
"--exclude", "**/1/3"])
739
737
self.restore_and_check()
739
def test_single_and_double_asterisks(self):
740
"""This compares a backup using --include-globbing-filelist with a single and double *."""
741
with open("testfiles/filelist.txt", 'w') as f:
742
f.write("+ testfiles/select2/*\n"
743
"- testfiles/select")
744
self.backup("full", "testfiles/", options=["--include-globbing-filelist=testfiles/filelist.txt"])
746
restore_dir = 'testfiles/restore_out'
747
restored = self.directory_tree_to_list_of_lists(restore_dir + "/select2")
748
with open("testfiles/filelist2.txt", 'w') as f:
749
f.write("+ testfiles/select2/**\n"
750
"- testfiles/select")
751
self.backup("full", "testfiles/", options=["--include-globbing-filelist=testfiles/filelist2.txt"])
753
restore_dir = 'testfiles/restore_out'
754
restored2 = self.directory_tree_to_list_of_lists(restore_dir + "/select2")
755
self.assertEqual(restored, restored2)
757
def test_single_and_double_asterisks_includes_excludes(self):
758
"""This compares a backup using --includes/--excludes with a single and double *."""
759
self.backup("full", "testfiles/",
760
options=["--include", "testfiles/select2/*",
761
"--exclude", "testfiles/select"])
763
restore_dir = 'testfiles/restore_out'
764
restored = self.directory_tree_to_list_of_lists(restore_dir + "/select2")
765
self.backup("full", "testfiles/",
766
options=["--include", "testfiles/select2/**",
767
"--exclude", "testfiles/select"])
769
restore_dir = 'testfiles/restore_out'
770
restored2 = self.directory_tree_to_list_of_lists(restore_dir + "/select2")
771
self.assertEqual(restored, restored2)
741
774
class TestTrailingSlash(IncludeExcludeFunctionalTest):
742
775
""" Test to check that a trailing slash works as expected
743
776
Exhibits the issue reported in Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)."""
759
792
self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"])
760
793
self.restore_and_check()
762
@unittest.expectedFailure
763
795
def test_exclude_filelist_trailing_slashes_single_wildcards_excludes(self):
764
796
"""test_exclude_filelist_trailing_slashes with single wildcards in excludes."""
765
# Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
797
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
766
798
with open("testfiles/filelist.txt", 'w') as f:
767
799
f.write("+ testfiles/select/1/2/1/\n"
768
800
"- */select/1/2/\n"
771
803
self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"])
772
804
self.restore_and_check()
774
@unittest.expectedFailure
775
806
def test_exclude_filelist_trailing_slashes_double_wildcards_excludes(self):
776
807
"""test_exclude_filelist_trailing_slashes with double wildcards in excludes."""
777
# Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
808
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
778
809
with open("testfiles/filelist.txt", 'w') as f:
779
810
f.write("+ testfiles/select/1/2/1/\n"
783
814
self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"])
784
815
self.restore_and_check()
786
@unittest.expectedFailure
787
def test_exclude_filelist_trailing_slashes_double_wildcards_excludes(self):
788
"""test_exclude_filelist_trailing_slashes with double wildcards in excludes."""
789
# Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) and likely
790
# Todo: Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
817
def test_exclude_filelist_trailing_slashes_double_wildcards_excludes_2(self):
818
"""second test_exclude_filelist_trailing_slashes with double wildcards in excludes."""
819
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482) and
820
# Regression test for Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371)
791
821
with open("testfiles/filelist.txt", 'w') as f:
792
822
f.write("+ **/1/2/1/\n"
796
826
self.backup("full", "testfiles/select/1", options=["--exclude-filelist=testfiles/filelist.txt"])
797
827
self.restore_and_check()
799
@unittest.expectedFailure
800
829
def test_exclude_filelist_trailing_slashes_wildcards(self):
801
830
"""test_commandline_asterisks_single_excludes_only with trailing slashes."""
802
# Todo: Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
831
# Regression test for Bug #932482 (https://bugs.launchpad.net/duplicity/+bug/932482)
803
832
self.backup("full", "testfiles/select/1",
804
833
options=["--include", "testfiles/select/1/2/1/",
805
834
"--exclude", "testfiles/*/1/2/",
807
836
"--exclude", "*/select/1/3/"])
808
837
self.restore_and_check()
840
class TestGlobbingReplacement(IncludeExcludeFunctionalTest):
841
""" This tests the behaviour of the extended shell globbing pattern replacement functions."""
842
# See the manual for a description of behaviours, but in summary:
843
# * can be expanded to any string of characters not containing "/"
844
# ? expands to any character except "/" and
845
# [...] expands to a single character of those characters specified (ranges are acceptable).
846
# The new special pattern, **, expands to any string of characters whether or not it contains "/".
847
# Furthermore, if the pattern starts with "ignorecase:" (case insensitive), then this prefix will be
848
# removed and any character in the string can be replaced with an upper- or lowercase version of itself.
850
def test_globbing_replacement_in_includes(self):
851
""" Test behaviour of the extended shell globbing pattern replacement functions in both include and exclude"""
852
# Identical to test_include_exclude_basic with globbing characters added to both include and exclude lines
853
# Exhibits the issue reported in Bug #884371 (https://bugs.launchpad.net/duplicity/+bug/884371).
854
# See above and the unit tests for more granularity on the issue.
855
self.backup("full", "testfiles/select2",
856
options=["--include", "testfiles/select2/**/3sub3sub2/3sub3su?2_file.txt", # Note ** and ? added
857
"--exclude", "testfiles/select2/*/3s*1", # Note * added in both directory and filename
858
"--exclude", "testfiles/select2/**/2sub1sub3", # Note ** added
859
"--exclude", "ignorecase:testfiles/select2/2/2sub1/2Sub1Sub2", # Note ignorecase added
860
"--include", "ignorecase:testfiles/sel[w,u,e,q]ct2/2/2S?b1", # Note ignorecase, [] and
862
"--exclude", "testfiles/select2/1/1sub3/1s[w,u,p,q]b3sub2", # Note [] added
863
"--exclude", "testfiles/select2/1/1sub[1-4]/1sub3sub1", # Note [range] added
864
"--include", "testfiles/select2/*/1sub2/1s[w,u,p,q]b2sub1", # Note * and [] added
865
"--exclude", "testfiles/select2/1/1sub1/1sub1sub3/1su?1sub3_file.txt", # Note ? added
866
"--exclude", "testfiles/select2/1/1*1/1sub1sub2", # Note * added
867
"--exclude", "testfiles/select2/1/1sub2",
868
"--include", "testfiles/select[2-4]/*.py", # Note * and [range] added
869
"--include", "testfiles/*2/3", # Note * added
870
"--include", "**/select2/1", # Note ** added
871
"--exclude", "testfiles/select2/**"])
873
restore_dir = 'testfiles/restore_out'
874
restored = self.directory_tree_to_list_of_lists(restore_dir)
875
self.assertEqual(restored, self.expected_restored_tree)
810
877
if __name__ == "__main__":