From 0e3bba7b640269595b2ed791fa2b9b18dd006bb7 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Wed, 25 May 2016 22:01:38 +0200 Subject: [PATCH 1/2] Don't rebuild command line parser for each invocation Makes tests faster --- borg/archiver.py | 8 ++++---- setup.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/borg/archiver.py b/borg/archiver.py index 96ac6bee0..d9eebeebb 100644 --- a/borg/archiver.py +++ b/borg/archiver.py @@ -96,9 +96,10 @@ def wrapper(self, args, repository, key, manifest, **kwargs): class Archiver: - def __init__(self, lock_wait=None): + def __init__(self, lock_wait=None, prog=None): self.exit_code = EXIT_SUCCESS self.lock_wait = lock_wait + self.parser = self.build_parser(prog) def print_error(self, msg, *args): msg = args and msg % args or msg @@ -1118,7 +1119,7 @@ def preprocess_args(self, args): self.print_warning(warning) return args - def build_parser(self, args=None, prog=None): + def build_parser(self, prog=None): common_parser = argparse.ArgumentParser(add_help=False, prog=prog) common_group = common_parser.add_argument_group('Common options') @@ -2062,8 +2063,7 @@ def parse_args(self, args=None): # We can't use argparse for "serve" since we don't want it to show up in "Available commands" if args: args = self.preprocess_args(args) - parser = self.build_parser(args) - args = parser.parse_args(args or ['-h']) + args = self.parser.parse_args(args or ['-h']) update_excludes(args) return args diff --git a/setup.py b/setup.py index 2ded99080..4f0159acc 100644 --- a/setup.py +++ b/setup.py @@ -159,7 +159,7 @@ def run(self): print('generating usage docs') # allows us to build docs without the C modules fully loaded during help generation from borg.archiver import Archiver - parser = Archiver().build_parser(prog='borg') + parser = Archiver(prog='borg').parser choices = {} for action in parser._actions: if action.choices is not None: From 478a6f29b6abbb024d55f00c637473be20ab2632 Mon Sep 17 00:00:00 2001 From: Marian Beermann Date: Wed, 25 May 2016 22:29:38 +0200 Subject: [PATCH 2/2] Lower PBKDF2 iteration count for the tests This cuts testing time to about one third for me. --- conftest.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index 450ff10a7..95bca39fc 100644 --- a/conftest.py +++ b/conftest.py @@ -27,7 +27,12 @@ from borg.testsuite import has_lchflags, no_lchlfags_because, has_llfuse from borg.testsuite.platform import fakeroot_detected -from borg import xattr +from borg import xattr, constants + + +def pytest_configure(config): + # no fixture-based monkey-patching since star-imports are used for the constants module + constants.PBKDF2_ITERATIONS = 1 def pytest_report_header(config, startdir):