1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-26 01:37:20 +00:00

--patterns-from was accessing args.roots instead of args.paths

add a test case that parses a command containing --patterns-from
This commit is contained in:
Alexander 'Leo' Bergolth 2017-02-28 12:01:37 +01:00
parent 7c9c4b61d7
commit 5cd424e4be
2 changed files with 18 additions and 1 deletions

View file

@ -407,7 +407,7 @@ def __call__(self, parser, args, values, option_string=None):
self.parse(f, args) self.parse(f, args)
def parse(self, fobj, args): def parse(self, fobj, args):
load_pattern_file(fobj, args.roots, args.patterns) load_pattern_file(fobj, args.paths, args.patterns)
class ArgparseExcludeFileAction(ArgparsePatternFileAction): class ArgparseExcludeFileAction(ArgparsePatternFileAction):

View file

@ -231,6 +231,7 @@ def setUp(self):
self.keys_path = os.path.join(self.tmpdir, 'keys') self.keys_path = os.path.join(self.tmpdir, 'keys')
self.cache_path = os.path.join(self.tmpdir, 'cache') self.cache_path = os.path.join(self.tmpdir, 'cache')
self.exclude_file_path = os.path.join(self.tmpdir, 'excludes') self.exclude_file_path = os.path.join(self.tmpdir, 'excludes')
self.patterns_file_path = os.path.join(self.tmpdir, 'patterns')
os.environ['BORG_KEYS_DIR'] = self.keys_path os.environ['BORG_KEYS_DIR'] = self.keys_path
os.environ['BORG_CACHE_DIR'] = self.cache_path os.environ['BORG_CACHE_DIR'] = self.cache_path
os.mkdir(self.input_path) os.mkdir(self.input_path)
@ -240,6 +241,8 @@ def setUp(self):
os.mkdir(self.cache_path) os.mkdir(self.cache_path)
with open(self.exclude_file_path, 'wb') as fd: with open(self.exclude_file_path, 'wb') as fd:
fd.write(b'input/file2\n# A comment line, then a blank line\n\n') fd.write(b'input/file2\n# A comment line, then a blank line\n\n')
with open(self.patterns_file_path, 'wb') as fd:
fd.write(b'+input/file_important\n- input/file*\n# A comment line, then a blank line\n\n')
self._old_wd = os.getcwd() self._old_wd = os.getcwd()
os.chdir(self.tmpdir) os.chdir(self.tmpdir)
@ -907,9 +910,23 @@ def test_create_pattern(self):
'--pattern=+input/file_important', '--pattern=-input/file*', '--pattern=+input/file_important', '--pattern=-input/file*',
self.repository_location + '::test', 'input') self.repository_location + '::test', 'input')
self.assert_in("A input/file_important", output) self.assert_in("A input/file_important", output)
self.assert_in('x input/file1', output)
self.assert_in('x input/file2', output)
def test_create_pattern_file(self):
"""test file patterns during create"""
self.cmd('init', '--encryption=repokey', self.repository_location)
self.create_regular_file('file1', size=1024 * 80)
self.create_regular_file('file2', size=1024 * 80)
self.create_regular_file('otherfile', size=1024 * 80)
self.create_regular_file('file_important', size=1024 * 80)
output = self.cmd('create', '-v', '--list',
'--pattern=-input/otherfile', '--patterns-from=' + self.patterns_file_path,
self.repository_location + '::test', 'input')
self.assert_in("A input/file_important", output) self.assert_in("A input/file_important", output)
self.assert_in('x input/file1', output) self.assert_in('x input/file1', output)
self.assert_in('x input/file2', output) self.assert_in('x input/file2', output)
self.assert_in('x input/otherfile', output)
def test_extract_pattern_opt(self): def test_extract_pattern_opt(self):
self.cmd('init', '--encryption=repokey', self.repository_location) self.cmd('init', '--encryption=repokey', self.repository_location)