diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-05-31 12:13:26 +0100 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-06-06 14:33:59 +0000 |
commit | 09b0cf8a208c46440cdb4d59ef1388522f12857a (patch) | |
tree | 6dab6c64ac15465d20ef45a6ee3c562fc6e0baf9 | |
parent | 3660337905dada5ee6bd9419ff83b5a6819f6801 (diff) | |
download | buildstream-09b0cf8a208c46440cdb4d59ef1388522f12857a.tar.gz |
test:utils/site: Consolidate Git environment variables in a single place
We have two different 'site' files that are redundant and both define
some variables in BuildStream environment.
Moving all the git related ones in a single place.
-rw-r--r-- | src/buildstream/testing/_utils/site.py | 7 | ||||
-rw-r--r-- | tests/cachekey/cachekey.py | 4 | ||||
-rw-r--r-- | tests/format/junctions.py | 2 | ||||
-rw-r--r-- | tests/sources/git.py | 3 | ||||
-rw-r--r-- | tests/sources/no_fetch_cached.py | 2 | ||||
-rw-r--r-- | tests/testutils/repo/git.py | 16 | ||||
-rw-r--r-- | tests/testutils/site.py | 11 |
7 files changed, 15 insertions, 30 deletions
diff --git a/src/buildstream/testing/_utils/site.py b/src/buildstream/testing/_utils/site.py index 63689301e..dbb4b9769 100644 --- a/src/buildstream/testing/_utils/site.py +++ b/src/buildstream/testing/_utils/site.py @@ -2,6 +2,7 @@ # so we dont have to repeat this everywhere # import os +import subprocess import sys import platform @@ -11,6 +12,11 @@ from buildstream import _site, utils, ProgramNotFoundError try: 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('.')) + HAVE_OLD_GIT = version < (1, 8, 5) + GIT_ENV = { 'GIT_AUTHOR_DATE': '1320966000 +0200', 'GIT_AUTHOR_NAME': 'tomjon', @@ -22,6 +28,7 @@ try: except ProgramNotFoundError: GIT = None HAVE_GIT = False + HAVE_OLD_GIT = False GIT_ENV = dict() try: diff --git a/tests/cachekey/cachekey.py b/tests/cachekey/cachekey.py index e34c9ff04..dc202a94e 100644 --- a/tests/cachekey/cachekey.py +++ b/tests/cachekey/cachekey.py @@ -45,10 +45,10 @@ import os import pytest from buildstream.testing.runcli import cli # pylint: disable=unused-import -from buildstream.testing._utils.site import HAVE_BZR +from buildstream.testing._utils.site import HAVE_BZR, HAVE_GIT from buildstream.plugin import CoreWarnings from buildstream import _yaml -from tests.testutils.site import HAVE_GIT, IS_LINUX, MACHINE_ARCH +from tests.testutils.site import IS_LINUX, MACHINE_ARCH ############################################## diff --git a/tests/format/junctions.py b/tests/format/junctions.py index bc85f182d..a85308e39 100644 --- a/tests/format/junctions.py +++ b/tests/format/junctions.py @@ -10,7 +10,7 @@ from buildstream import _yaml from buildstream._exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import create_repo -from tests.testutils.site import HAVE_GIT +from buildstream.testing._utils.site import HAVE_GIT DATA_DIR = os.path.join( diff --git a/tests/sources/git.py b/tests/sources/git.py index b7b175ee6..e9cc369d7 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -34,8 +34,7 @@ from buildstream import _yaml from buildstream.plugin import CoreWarnings from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import create_repo - -from tests.testutils.site import HAVE_GIT, HAVE_OLD_GIT +from buildstream.testing._utils.site import HAVE_GIT, HAVE_OLD_GIT DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), diff --git a/tests/sources/no_fetch_cached.py b/tests/sources/no_fetch_cached.py index 69d28615a..fcbb42398 100644 --- a/tests/sources/no_fetch_cached.py +++ b/tests/sources/no_fetch_cached.py @@ -8,7 +8,7 @@ from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import create_repo -from tests.testutils.site import HAVE_GIT +from buildstream.testing._utils.site import HAVE_GIT DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), diff --git a/tests/testutils/repo/git.py b/tests/testutils/repo/git.py index 8ffd09c2f..f4e300b53 100644 --- a/tests/testutils/repo/git.py +++ b/tests/testutils/repo/git.py @@ -5,23 +5,13 @@ import subprocess import pytest from buildstream.testing import Repo -from .. import site - - -GIT_ENV = { - 'GIT_AUTHOR_DATE': '1320966000 +0200', - 'GIT_AUTHOR_NAME': 'tomjon', - 'GIT_AUTHOR_EMAIL': 'tom@jon.com', - 'GIT_COMMITTER_DATE': '1320966000 +0200', - 'GIT_COMMITTER_NAME': 'tomjon', - 'GIT_COMMITTER_EMAIL': 'tom@jon.com' -} +from buildstream.testing._utils.site import GIT, GIT_ENV, HAVE_GIT class Git(Repo): def __init__(self, directory, subdir): - if not site.HAVE_GIT: + if not HAVE_GIT: pytest.skip("git is not available") self.submodules = {} @@ -29,7 +19,7 @@ class Git(Repo): super(Git, self).__init__(directory, subdir) def _run_git(self, *args, **kwargs): - argv = [site.GIT] + argv = [GIT] argv.extend(args) if 'env' not in kwargs: kwargs['env'] = dict(GIT_ENV, PWD=self.repo) diff --git a/tests/testutils/site.py b/tests/testutils/site.py index a7ff415e3..6801ee066 100644 --- a/tests/testutils/site.py +++ b/tests/testutils/site.py @@ -2,7 +2,6 @@ # so we dont have to repeat this everywhere # import os -import subprocess import sys import platform @@ -11,16 +10,6 @@ from buildstream._platform import Platform try: - 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('.')) - HAVE_OLD_GIT = version < (1, 8, 5) -except ProgramNotFoundError: - HAVE_GIT = False - HAVE_OLD_GIT = False - -try: OSTREE_CLI = utils.get_host_tool('ostree') HAVE_OSTREE_CLI = True except ProgramNotFoundError: |