benchmarks: test with both the binary and the python code

we use forking mode always and either execute python with the archiver module or the "borg.exe" binary.
the cmd fixture alternates between 'python' and 'binary' mode and calls exec_cmd accordingly.
This commit is contained in:
Thomas Waldmann 2015-10-16 00:12:02 +02:00
parent a96770636c
commit 4b7c02775e
2 changed files with 18 additions and 6 deletions

View file

@ -71,10 +71,15 @@ class environment_variable:
os.environ[k] = v
def exec_cmd(*args, archiver=None, fork=False, **kw):
def exec_cmd(*args, archiver=None, fork=False, exe=None, **kw):
if fork:
try:
borg = (sys.executable, '-m', 'borg.archiver')
if exe is None:
borg = (sys.executable, '-m', 'borg.archiver')
elif isinstance(exe, str):
borg = (exe, )
elif not isinstance(exe, tuple):
raise ValueError('exe must be None, a tuple or a str')
output = subprocess.check_output(borg + args)
ret = 0
except subprocess.CalledProcessError as e:

View file

@ -13,10 +13,17 @@ import pytest
from .archiver import changedir, exec_cmd
# TODO: use fixture params to test python code and binary
@pytest.fixture
def cmd():
return exec_cmd
@pytest.fixture(params=['python', 'binary'])
def cmd(request):
if request.param == 'python':
exe = None
elif request.param == 'binary':
exe = 'borg.exe'
else:
raise ValueError("param must be 'python' or 'binary'")
def exec_fn(*args, **kw):
return exec_cmd(*args, exe=exe, fork=True, **kw)
return exec_fn
@pytest.yield_fixture