summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <ben.c.schubert@gmail.com>2019-03-01 09:48:08 +0000
committerBenjamin Schubert <ben.c.schubert@gmail.com>2019-03-01 10:00:23 +0000
commita2947e503c5c99386ba6e10be8f3d6b9e8a39cbb (patch)
treec1a887ffe63b09998525eb5bd8c6264fa2943092
parentfc2b42d63ac4ec1bc7727a1f7705613305060572 (diff)
downloadbuildstream-a2947e503c5c99386ba6e10be8f3d6b9e8a39cbb.tar.gz
tests: always use host tools from sites.py
This allows tests importing them to have access to the commands directly and removes the need from calling this multiple times This also fixes multiple bugs where the paths of the tests runners might not be canonical and tools would not get found correctly
-rw-r--r--tests/testutils/repo/bzr.py8
-rw-r--r--tests/testutils/repo/git.py7
-rw-r--r--tests/testutils/repo/ostree.py11
-rw-r--r--tests/testutils/site.py6
4 files changed, 17 insertions, 15 deletions
diff --git a/tests/testutils/repo/bzr.py b/tests/testutils/repo/bzr.py
index e8abdfee0..e159fa052 100644
--- a/tests/testutils/repo/bzr.py
+++ b/tests/testutils/repo/bzr.py
@@ -2,9 +2,9 @@ import os
import subprocess
import pytest
-from buildstream import utils
from .repo import Repo
-from ..site import HAVE_BZR
+from .. import site
+
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 site.HAVE_BZR:
pytest.skip("bzr is not available")
super(Bzr, self).__init__(directory, subdir)
- self.bzr = utils.get_host_tool('bzr')
+ self.bzr = site.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..183651180 100644
--- a/tests/testutils/repo/git.py
+++ b/tests/testutils/repo/git.py
@@ -4,7 +4,8 @@ import shutil
import subprocess
from .repo import Repo
-from ..site import HAVE_GIT
+from .. import site
+
GIT_ENV = {
'GIT_AUTHOR_DATE': '1320966000 +0200',
@@ -19,7 +20,7 @@ GIT_ENV = {
class Git(Repo):
def __init__(self, directory, subdir):
- if not HAVE_GIT:
+ if not site.HAVE_GIT:
pytest.skip("git is not available")
self.submodules = {}
@@ -27,7 +28,7 @@ class Git(Repo):
super(Git, self).__init__(directory, subdir)
def _run_git(self, *args, **kwargs):
- argv = ['git']
+ argv = [site.GIT]
argv.extend(args)
if 'env' not in kwargs:
kwargs['env'] = dict(GIT_ENV, PWD=self.repo)
diff --git a/tests/testutils/repo/ostree.py b/tests/testutils/repo/ostree.py
index e240de113..1cd7c8979 100644
--- a/tests/testutils/repo/ostree.py
+++ b/tests/testutils/repo/ostree.py
@@ -2,22 +2,23 @@ import pytest
import subprocess
from .repo import Repo
-from ..site import HAVE_OSTREE_CLI, HAVE_OSTREE
+from .. import site
class OSTree(Repo):
def __init__(self, directory, subdir):
- if not HAVE_OSTREE_CLI or not HAVE_OSTREE:
+ if not site.HAVE_OSTREE_CLI or not site.HAVE_OSTREE:
pytest.skip("ostree cli is not available")
super(OSTree, self).__init__(directory, subdir)
+ self.ostree = site.OSTREE_CLI
def create(self, directory):
- subprocess.call(['ostree', 'init',
+ subprocess.call([self.ostree, 'init',
'--repo', self.repo,
'--mode', 'archive-z2'])
- subprocess.call(['ostree', 'commit',
+ subprocess.call([self.ostree, 'commit',
'--repo', self.repo,
'--branch', 'master',
'--subject', 'Initial commit',
@@ -40,7 +41,7 @@ class OSTree(Repo):
def latest_commit(self):
output = subprocess.check_output([
- 'ostree', 'rev-parse',
+ self.ostree, 'rev-parse',
'--repo', self.repo,
'master'
])
diff --git a/tests/testutils/site.py b/tests/testutils/site.py
index 952b2618c..2f4143407 100644
--- a/tests/testutils/site.py
+++ b/tests/testutils/site.py
@@ -10,13 +10,13 @@ from buildstream import _site, utils, ProgramNotFoundError
from buildstream._platform import Platform
try:
- utils.get_host_tool('bzr')
+ BZR = utils.get_host_tool('bzr')
HAVE_BZR = True
except ProgramNotFoundError:
HAVE_BZR = False
try:
- utils.get_host_tool('git')
+ GIT = utils.get_host_tool('git')
HAVE_GIT = True
out = str(subprocess.check_output(['git', '--version']), "utf-8")
version = tuple(int(x) for x in out.split(' ')[2].split('.'))
@@ -26,7 +26,7 @@ except ProgramNotFoundError:
HAVE_OLD_GIT = False
try:
- utils.get_host_tool('ostree')
+ OSTREE_CLI = utils.get_host_tool('ostree')
HAVE_OSTREE_CLI = True
except ProgramNotFoundError:
HAVE_OSTREE_CLI = False