diff options
Diffstat (limited to 'tests/testutils')
-rw-r--r-- | tests/testutils/repo/bzr.py | 6 | ||||
-rw-r--r-- | tests/testutils/repo/git.py | 8 | ||||
-rw-r--r-- | tests/testutils/repo/ostree.py | 10 | ||||
-rw-r--r-- | tests/testutils/site.py | 27 |
4 files changed, 23 insertions, 28 deletions
diff --git a/tests/testutils/repo/bzr.py b/tests/testutils/repo/bzr.py index e8abdfee0..12abc47b5 100644 --- a/tests/testutils/repo/bzr.py +++ b/tests/testutils/repo/bzr.py @@ -4,7 +4,7 @@ import pytest from buildstream import utils from .repo import Repo -from ..site import HAVE_BZR +from ..site import BZR BZR_ENV = { "BZR_EMAIL": "Testy McTesterson <testy.mctesterson@example.com>" @@ -14,10 +14,10 @@ BZR_ENV = { class Bzr(Repo): def __init__(self, directory, subdir): - if not HAVE_BZR: + if not BZR: pytest.skip("bzr is not available") super(Bzr, self).__init__(directory, subdir) - self.bzr = utils.get_host_tool('bzr') + self.bzr = BZR def create(self, directory): branch_dir = os.path.join(self.repo, 'trunk') diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py index 3eb8c6577..a12ffaba3 100644 --- a/tests/testutils/repo/git.py +++ b/tests/testutils/repo/git.py @@ -4,7 +4,7 @@ import shutil import subprocess from .repo import Repo -from ..site import HAVE_GIT +from ..site import GIT GIT_ENV = { 'GIT_AUTHOR_DATE': '1320966000 +0200', @@ -19,7 +19,7 @@ GIT_ENV = { class Git(Repo): def __init__(self, directory, subdir): - if not HAVE_GIT: + if not GIT: pytest.skip("git is not available") self.submodules = {} @@ -27,8 +27,8 @@ class Git(Repo): super(Git, self).__init__(directory, subdir) def _run_git(self, *args, **kwargs): - argv = ['git'] - argv.extend(args) + argv = [GIT, *args] + if 'env' not in kwargs: kwargs['env'] = dict(GIT_ENV, PWD=self.repo) kwargs.setdefault('cwd', self.repo) diff --git a/tests/testutils/repo/ostree.py b/tests/testutils/repo/ostree.py index e240de113..d52bf12f2 100644 --- a/tests/testutils/repo/ostree.py +++ b/tests/testutils/repo/ostree.py @@ -2,22 +2,22 @@ import pytest import subprocess from .repo import Repo -from ..site import HAVE_OSTREE_CLI, HAVE_OSTREE +from ..site import OSTREE_CLI, HAVE_OSTREE class OSTree(Repo): def __init__(self, directory, subdir): - if not HAVE_OSTREE_CLI or not HAVE_OSTREE: + if not OSTREE_CLI or not HAVE_OSTREE: pytest.skip("ostree cli is not available") super(OSTree, self).__init__(directory, subdir) def create(self, directory): - subprocess.call(['ostree', 'init', + subprocess.call([OSTREE_CLI, 'init', '--repo', self.repo, '--mode', 'archive-z2']) - subprocess.call(['ostree', 'commit', + subprocess.call([OSTREE_CLI, 'commit', '--repo', self.repo, '--branch', 'master', '--subject', 'Initial commit', @@ -40,7 +40,7 @@ class OSTree(Repo): def latest_commit(self): output = subprocess.check_output([ - 'ostree', 'rev-parse', + OSTREE_CLI, 'rev-parse', '--repo', self.repo, 'master' ]) diff --git a/tests/testutils/site.py b/tests/testutils/site.py index 952b2618c..9a9aca200 100644 --- a/tests/testutils/site.py +++ b/tests/testutils/site.py @@ -10,26 +10,23 @@ from buildstream import _site, utils, ProgramNotFoundError from buildstream._platform import Platform try: - utils.get_host_tool('bzr') - HAVE_BZR = True + BZR = utils.get_host_tool('bzr') except ProgramNotFoundError: - HAVE_BZR = False + BZR = None try: - utils.get_host_tool('git') - HAVE_GIT = True + GIT = utils.get_host_tool('git') out = str(subprocess.check_output(['git', '--version']), "utf-8") version = tuple(int(x) for x in out.split(' ')[2].split('.')) HAVE_OLD_GIT = version < (1, 8, 5) except ProgramNotFoundError: - HAVE_GIT = False + GIT = None HAVE_OLD_GIT = False try: - utils.get_host_tool('ostree') - HAVE_OSTREE_CLI = True + OSTREE_CLI = utils.get_host_tool('ostree') except ProgramNotFoundError: - HAVE_OSTREE_CLI = False + OSTREE_CLI = None try: from buildstream import _ostree @@ -38,18 +35,16 @@ except (ImportError, ValueError): HAVE_OSTREE = False try: - utils.get_host_tool('bwrap') - HAVE_BWRAP = True + BWRAP = utils.get_host_tool('bwrap') HAVE_BWRAP_JSON_STATUS = _site.get_bwrap_version() >= (0, 3, 2) except ProgramNotFoundError: - HAVE_BWRAP = False + BWRAP = None HAVE_BWRAP_JSON_STATUS = False try: - utils.get_host_tool('lzip') - HAVE_LZIP = True + LZIP = utils.get_host_tool('lzip') except ProgramNotFoundError: - HAVE_LZIP = False + LZIP = False try: import arpy @@ -65,7 +60,7 @@ if not IS_LINUX: HAVE_SANDBOX = True # fallback to a chroot sandbox on unix elif IS_WSL: HAVE_SANDBOX = False # Sandboxes are inoperable under WSL due to lack of FUSE -elif IS_LINUX and HAVE_BWRAP: +elif IS_LINUX and BWRAP: HAVE_SANDBOX = True else: HAVE_SANDBOX = False |