|
@@ -562,6 +562,39 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
|
|
self.cmd('extract', '--exclude-from=' + self.exclude_file_path, self.repository_location + '::test')
|
|
|
self.assert_equal(sorted(os.listdir('output/input')), ['file3'])
|
|
|
|
|
|
+ def test_extract_with_pattern(self):
|
|
|
+ self.cmd("init", self.repository_location)
|
|
|
+ self.create_regular_file("file1", size=1024 * 80)
|
|
|
+ self.create_regular_file("file2", size=1024 * 80)
|
|
|
+ self.create_regular_file("file3", size=1024 * 80)
|
|
|
+ self.create_regular_file("file4", size=1024 * 80)
|
|
|
+ self.create_regular_file("file333", size=1024 * 80)
|
|
|
+
|
|
|
+ self.cmd("create", self.repository_location + "::test", "input")
|
|
|
+
|
|
|
+ # Extract everything with regular expression
|
|
|
+ with changedir("output"):
|
|
|
+ self.cmd("extract", self.repository_location + "::test", "re:.*")
|
|
|
+ self.assert_equal(sorted(os.listdir("output/input")), ["file1", "file2", "file3", "file333", "file4"])
|
|
|
+ shutil.rmtree("output/input")
|
|
|
+
|
|
|
+ # Extract with pattern while also excluding files
|
|
|
+ with changedir("output"):
|
|
|
+ self.cmd("extract", "--exclude=re:file[34]$", self.repository_location + "::test", r"re:file\d$")
|
|
|
+ self.assert_equal(sorted(os.listdir("output/input")), ["file1", "file2"])
|
|
|
+ shutil.rmtree("output/input")
|
|
|
+
|
|
|
+ # Combine --exclude with pattern for extraction
|
|
|
+ with changedir("output"):
|
|
|
+ self.cmd("extract", "--exclude=input/file1", self.repository_location + "::test", "re:file[12]$")
|
|
|
+ self.assert_equal(sorted(os.listdir("output/input")), ["file2"])
|
|
|
+ shutil.rmtree("output/input")
|
|
|
+
|
|
|
+ # Multiple pattern
|
|
|
+ with changedir("output"):
|
|
|
+ self.cmd("extract", self.repository_location + "::test", "fm:input/file1", "fm:*file33*", "input/file2")
|
|
|
+ self.assert_equal(sorted(os.listdir("output/input")), ["file1", "file2", "file333"])
|
|
|
+
|
|
|
def test_exclude_caches(self):
|
|
|
self.cmd('init', self.repository_location)
|
|
|
self.create_regular_file('file1', size=1024 * 80)
|