diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-06-06 15:04:18 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-06-06 15:04:18 +0000 |
commit | ff0555ab712d13ec3a7b8388684fdd2ea4e82926 (patch) | |
tree | 1a930b1369ebb96fc317c3d51d8807ce0bcf82c9 | |
parent | 17da93ab01cf538fc855492b621916eb32bbf77d (diff) | |
parent | 48254a42595369c6feb738df9fcdb7c79b46dd1a (diff) | |
download | buildstream-ff0555ab712d13ec3a7b8388684fdd2ea4e82926.tar.gz |
Merge branch 'bschubert/site-consolidation' into 'master'
Remove tests/testutils/site.py and move everything to buildstream/testing/_utils/site.py
See merge request BuildStream/buildstream!1375
42 files changed, 91 insertions, 135 deletions
diff --git a/src/buildstream/testing/_utils/site.py b/src/buildstream/testing/_utils/site.py index 54c5b467b..9e66b804e 100644 --- a/src/buildstream/testing/_utils/site.py +++ b/src/buildstream/testing/_utils/site.py @@ -2,15 +2,22 @@ # so we dont have to repeat this everywhere # import os +import subprocess import sys import platform from buildstream import _site, utils, ProgramNotFoundError +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) + GIT_ENV = { 'GIT_AUTHOR_DATE': '1320966000 +0200', 'GIT_AUTHOR_NAME': 'tomjon', @@ -22,9 +29,20 @@ try: except ProgramNotFoundError: GIT = None HAVE_GIT = False + HAVE_OLD_GIT = False GIT_ENV = dict() try: + BZR = utils.get_host_tool('bzr') + HAVE_BZR = True + BZR_ENV = { + "BZR_EMAIL": "Testy McTesterson <testy.mctesterson@example.com>" + } +except ProgramNotFoundError: + HAVE_BZR = False + BZR_ENV = {} + +try: utils.get_host_tool('bwrap') HAVE_BWRAP = True HAVE_BWRAP_JSON_STATUS = _site.get_bwrap_version() >= (0, 3, 2) @@ -32,6 +50,18 @@ except ProgramNotFoundError: HAVE_BWRAP = False HAVE_BWRAP_JSON_STATUS = False +try: + utils.get_host_tool('lzip') + HAVE_LZIP = True +except ProgramNotFoundError: + HAVE_LZIP = False + +try: + import arpy # pylint: disable=unused-import + HAVE_ARPY = True +except ImportError: + HAVE_ARPY = False + IS_LINUX = os.getenv('BST_FORCE_BACKEND', sys.platform).startswith('linux') IS_WSL = (IS_LINUX and 'Microsoft' in platform.uname().release) IS_WINDOWS = (os.name == 'nt') @@ -44,3 +74,5 @@ elif IS_LINUX and HAVE_BWRAP: HAVE_SANDBOX = True else: HAVE_SANDBOX = False + +MACHINE_ARCH = Platform.get_host_arch() diff --git a/tests/cachekey/cachekey.py b/tests/cachekey/cachekey.py index 2e8c29805..7c5d90d1f 100644 --- a/tests/cachekey/cachekey.py +++ b/tests/cachekey/cachekey.py @@ -45,9 +45,9 @@ import os import pytest from buildstream.testing.runcli import cli # pylint: disable=unused-import +from buildstream.testing._utils.site import HAVE_BZR, HAVE_GIT, IS_LINUX, MACHINE_ARCH from buildstream.plugin import CoreWarnings from buildstream import _yaml -from tests.testutils.site import HAVE_BZR, HAVE_GIT, IS_LINUX, MACHINE_ARCH ############################################## diff --git a/tests/examples/autotools.py b/tests/examples/autotools.py index 03b98a5f4..ca311c4bb 100644 --- a/tests/examples/autotools.py +++ b/tests/examples/autotools.py @@ -6,7 +6,7 @@ import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains -from tests.testutils.site import HAVE_BWRAP, IS_LINUX, MACHINE_ARCH +from buildstream.testing._utils.site import HAVE_BWRAP, IS_LINUX, MACHINE_ARCH pytestmark = pytest.mark.integration diff --git a/tests/examples/developing.py b/tests/examples/developing.py index 6e17a7bc1..c2b950c01 100644 --- a/tests/examples/developing.py +++ b/tests/examples/developing.py @@ -6,8 +6,8 @@ import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains +from buildstream.testing._utils.site import HAVE_BWRAP, IS_LINUX, MACHINE_ARCH import tests.testutils.patch as patch -from tests.testutils.site import HAVE_BWRAP, IS_LINUX, MACHINE_ARCH pytestmark = pytest.mark.integration diff --git a/tests/examples/first-project.py b/tests/examples/first-project.py index d95c8293c..84ab7aa61 100644 --- a/tests/examples/first-project.py +++ b/tests/examples/first-project.py @@ -6,7 +6,7 @@ import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains -from tests.testutils.site import IS_LINUX +from buildstream.testing._utils.site import IS_LINUX pytestmark = pytest.mark.integration diff --git a/tests/examples/flatpak-autotools.py b/tests/examples/flatpak-autotools.py index 8af564eb1..2418807c0 100644 --- a/tests/examples/flatpak-autotools.py +++ b/tests/examples/flatpak-autotools.py @@ -6,7 +6,7 @@ import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains -from tests.testutils.site import HAVE_OSTREE, IS_LINUX, MACHINE_ARCH +from buildstream.testing._utils.site import IS_LINUX, MACHINE_ARCH pytestmark = pytest.mark.integration @@ -17,6 +17,15 @@ DATA_DIR = os.path.join( ) +try: + from bst_plugins_experimental.sources import _ostree # pylint: disable=unused-import + # Even when we have the plugin, it might be missing dependencies. This requires + # bst_plugins_experimantal to be fully installed, with host ostree dependencies + HAVE_OSTREE_PLUGIN = True +except (ImportError, ValueError): + HAVE_OSTREE_PLUGIN = False + + # FIXME: Workaround a setuptools bug which fails to include symbolic # links in the source distribution. # @@ -37,7 +46,7 @@ def workaround_setuptools_bug(project): # amhello project for this. @pytest.mark.skipif(MACHINE_ARCH != 'x86-64', reason='Examples are written for x86-64') -@pytest.mark.skipif(not IS_LINUX or not HAVE_OSTREE, reason='Only available on linux with ostree') +@pytest.mark.skipif(not IS_LINUX or not HAVE_OSTREE_PLUGIN, reason='Only available on linux with ostree') @pytest.mark.datafiles(DATA_DIR) def test_autotools_build(cli, datafiles): project = str(datafiles) @@ -60,7 +69,7 @@ def test_autotools_build(cli, datafiles): # Test running an executable built with autotools @pytest.mark.skipif(MACHINE_ARCH != 'x86-64', reason='Examples are written for x86-64') -@pytest.mark.skipif(not IS_LINUX or not HAVE_OSTREE, reason='Only available on linux with ostree') +@pytest.mark.skipif(not IS_LINUX or not HAVE_OSTREE_PLUGIN, reason='Only available on linux with ostree') @pytest.mark.datafiles(DATA_DIR) def test_autotools_run(cli, datafiles): project = str(datafiles) diff --git a/tests/examples/integration-commands.py b/tests/examples/integration-commands.py index ad5119600..ad794351f 100644 --- a/tests/examples/integration-commands.py +++ b/tests/examples/integration-commands.py @@ -5,7 +5,7 @@ import os import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_BWRAP, IS_LINUX, MACHINE_ARCH +from buildstream.testing._utils.site import HAVE_BWRAP, IS_LINUX, MACHINE_ARCH pytestmark = pytest.mark.integration diff --git a/tests/examples/junctions.py b/tests/examples/junctions.py index 695bfe8c8..bb88e5068 100644 --- a/tests/examples/junctions.py +++ b/tests/examples/junctions.py @@ -5,7 +5,7 @@ import os import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import IS_LINUX, HAVE_BWRAP, MACHINE_ARCH +from buildstream.testing._utils.site import HAVE_BWRAP, IS_LINUX, MACHINE_ARCH pytestmark = pytest.mark.integration diff --git a/tests/examples/running-commands.py b/tests/examples/running-commands.py index 7089f143e..23b3e6467 100644 --- a/tests/examples/running-commands.py +++ b/tests/examples/running-commands.py @@ -5,7 +5,7 @@ import os import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import IS_LINUX, HAVE_BWRAP, MACHINE_ARCH +from buildstream.testing._utils.site import HAVE_BWRAP, IS_LINUX, MACHINE_ARCH pytestmark = pytest.mark.integration 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/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 835f084cf..556bf811c 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -9,10 +9,10 @@ import subprocess import pytest from buildstream.testing import cli # pylint: disable=unused-import +from buildstream.testing._utils.site import IS_WINDOWS from buildstream import _yaml from buildstream._exceptions import ErrorDomain, LoadErrorReason -from tests.testutils.site import IS_WINDOWS from tests.testutils import generate_junction, yaml_file_get_provenance from . import configure_project diff --git a/tests/integration/artifact.py b/tests/integration/artifact.py index 27bf1a857..56c516e67 100644 --- a/tests/integration/artifact.py +++ b/tests/integration/artifact.py @@ -27,8 +27,10 @@ import shutil import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import +from buildstream.testing._utils.site import HAVE_SANDBOX + from tests.testutils import create_artifact_share -from tests.testutils.site import HAVE_SANDBOX + pytestmark = pytest.mark.integration diff --git a/tests/integration/autotools.py b/tests/integration/autotools.py index 9b462013b..c4bf429f5 100644 --- a/tests/integration/autotools.py +++ b/tests/integration/autotools.py @@ -6,7 +6,7 @@ import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/build-uid.py b/tests/integration/build-uid.py index d11153d55..2ebf230a1 100644 --- a/tests/integration/build-uid.py +++ b/tests/integration/build-uid.py @@ -5,7 +5,7 @@ import os import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_BWRAP, IS_LINUX, HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_BWRAP, HAVE_SANDBOX, IS_LINUX pytestmark = pytest.mark.integration diff --git a/tests/integration/cachedfail.py b/tests/integration/cachedfail.py index 96cfdb723..a2273a06d 100644 --- a/tests/integration/cachedfail.py +++ b/tests/integration/cachedfail.py @@ -7,10 +7,10 @@ import pytest from buildstream import _yaml from buildstream._exceptions import ErrorDomain from buildstream.testing import cli_integration as cli # pylint: disable=unused-import +from buildstream.testing._utils.site import HAVE_BWRAP, HAVE_SANDBOX, IS_LINUX from tests.conftest import clean_platform_cache from tests.testutils import create_artifact_share -from tests.testutils.site import HAVE_BWRAP, IS_LINUX, HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/cmake.py b/tests/integration/cmake.py index 87b850e2d..84ea96af2 100644 --- a/tests/integration/cmake.py +++ b/tests/integration/cmake.py @@ -6,7 +6,7 @@ import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/compose.py b/tests/integration/compose.py index 23b90a2df..2b37942fa 100644 --- a/tests/integration/compose.py +++ b/tests/integration/compose.py @@ -8,7 +8,7 @@ from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import walk_dir -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/make.py b/tests/integration/make.py index 78a2c8f91..664e7ca7a 100644 --- a/tests/integration/make.py +++ b/tests/integration/make.py @@ -6,7 +6,7 @@ import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/manual.py b/tests/integration/manual.py index 1d193b587..b3124a852 100644 --- a/tests/integration/manual.py +++ b/tests/integration/manual.py @@ -7,7 +7,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/messages.py b/tests/integration/messages.py index 51385de5d..edfb435ae 100644 --- a/tests/integration/messages.py +++ b/tests/integration/messages.py @@ -26,7 +26,7 @@ import pytest from buildstream import _yaml from buildstream._exceptions import ErrorDomain from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/pip_element.py b/tests/integration/pip_element.py index 834ce4c63..91dcaa39e 100644 --- a/tests/integration/pip_element.py +++ b/tests/integration/pip_element.py @@ -9,8 +9,9 @@ from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains +from buildstream.testing._utils.site import HAVE_SANDBOX + from tests.testutils import setup_pypi_repo # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/pip_source.py b/tests/integration/pip_source.py index 91fcbc6a8..632b5ae24 100644 --- a/tests/integration/pip_source.py +++ b/tests/integration/pip_source.py @@ -8,8 +8,9 @@ from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import from buildstream.testing.integration import assert_contains +from buildstream.testing._utils.site import HAVE_SANDBOX + from tests.testutils.python_repo import setup_pypi_repo # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/pullbuildtrees.py b/tests/integration/pullbuildtrees.py index c562149df..af9186b1b 100644 --- a/tests/integration/pullbuildtrees.py +++ b/tests/integration/pullbuildtrees.py @@ -7,10 +7,10 @@ import shutil import pytest from buildstream.testing import cli, cli_integration as cli2 # pylint: disable=unused-import +from buildstream.testing._utils.site import HAVE_SANDBOX from buildstream._exceptions import ErrorDomain, LoadErrorReason from tests.testutils import create_artifact_share -from tests.testutils.site import HAVE_SANDBOX DATA_DIR = os.path.join( diff --git a/tests/integration/sandbox-bwrap.py b/tests/integration/sandbox-bwrap.py index e1c676ea5..d08076f5a 100644 --- a/tests/integration/sandbox-bwrap.py +++ b/tests/integration/sandbox-bwrap.py @@ -7,7 +7,7 @@ import pytest from buildstream._exceptions import ErrorDomain from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_BWRAP, HAVE_BWRAP_JSON_STATUS +from buildstream.testing._utils.site import HAVE_BWRAP, HAVE_BWRAP_JSON_STATUS pytestmark = pytest.mark.integration diff --git a/tests/integration/script.py b/tests/integration/script.py index cb95aae36..1025709f4 100644 --- a/tests/integration/script.py +++ b/tests/integration/script.py @@ -6,7 +6,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/shell.py b/tests/integration/shell.py index 4f08504c9..868064d5b 100644 --- a/tests/integration/shell.py +++ b/tests/integration/shell.py @@ -6,7 +6,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py index e371884e4..78dad8747 100644 --- a/tests/integration/shellbuildtrees.py +++ b/tests/integration/shellbuildtrees.py @@ -8,9 +8,9 @@ import pytest from buildstream.testing import cli, cli_integration # pylint: disable=unused-import from buildstream._exceptions import ErrorDomain +from buildstream.testing._utils.site import HAVE_SANDBOX from tests.testutils import create_artifact_share -from tests.testutils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/sockets.py b/tests/integration/sockets.py index f9ad45bd0..763238baf 100644 --- a/tests/integration/sockets.py +++ b/tests/integration/sockets.py @@ -5,7 +5,7 @@ import os import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/source-determinism.py b/tests/integration/source-determinism.py index de5b36e6f..4590d4102 100644 --- a/tests/integration/source-determinism.py +++ b/tests/integration/source-determinism.py @@ -6,7 +6,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX DATA_DIR = os.path.join( diff --git a/tests/integration/stack.py b/tests/integration/stack.py index 9248f5b27..9d6b38345 100644 --- a/tests/integration/stack.py +++ b/tests/integration/stack.py @@ -5,7 +5,7 @@ import os import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/symlinks.py b/tests/integration/symlinks.py index 9c58fa40b..ed6ee109c 100644 --- a/tests/integration/symlinks.py +++ b/tests/integration/symlinks.py @@ -5,7 +5,7 @@ import os import pytest from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/integration/workspace.py b/tests/integration/workspace.py index e44e26def..fff9518a3 100644 --- a/tests/integration/workspace.py +++ b/tests/integration/workspace.py @@ -6,7 +6,7 @@ import pytest from buildstream import _yaml from buildstream.testing import cli_integration as cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_SANDBOX +from buildstream.testing._utils.site import HAVE_SANDBOX pytestmark = pytest.mark.integration diff --git a/tests/sandboxes/missing_dependencies.py b/tests/sandboxes/missing_dependencies.py index 1f2a50422..ee346010e 100644 --- a/tests/sandboxes/missing_dependencies.py +++ b/tests/sandboxes/missing_dependencies.py @@ -7,9 +7,9 @@ import pytest from buildstream import _yaml from buildstream._exceptions import ErrorDomain +from buildstream.testing._utils.site import IS_LINUX from buildstream.testing import cli # pylint: disable=unused-import -from tests.testutils.site import IS_LINUX # Project directory DATA_DIR = os.path.join( diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py index a11932a49..4a66d89b3 100644 --- a/tests/sources/bzr.py +++ b/tests/sources/bzr.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_BZR +from buildstream.testing._utils.site import HAVE_BZR DATA_DIR = os.path.join( os.path.dirname(os.path.realpath(__file__)), diff --git a/tests/sources/deb.py b/tests/sources/deb.py index 69b7c78df..bdde20aaa 100644 --- a/tests/sources/deb.py +++ b/tests/sources/deb.py @@ -9,7 +9,7 @@ import pytest from buildstream._exceptions import ErrorDomain from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import -from tests.testutils.site import HAVE_ARPY +from buildstream.testing._utils.site import HAVE_ARPY from . import list_dir_contents 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/local.py b/tests/sources/local.py index f568fee78..fb5d36081 100644 --- a/tests/sources/local.py +++ b/tests/sources/local.py @@ -7,8 +7,8 @@ import pytest from buildstream import _yaml from buildstream._exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import +from buildstream.testing._utils.site import HAVE_SANDBOX from tests.testutils import filetypegenerator -from tests.testutils.site import HAVE_SANDBOX 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/sources/tar.py b/tests/sources/tar.py index 8446f485f..a6c1a4d9f 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -13,8 +13,8 @@ import pytest from buildstream._exceptions import ErrorDomain from buildstream import _yaml from buildstream.testing import cli # pylint: disable=unused-import +from buildstream.testing._utils.site import HAVE_LZIP from tests.testutils.file_server import create_file_server -from tests.testutils.site import HAVE_LZIP from . import list_dir_contents DATA_DIR = os.path.join( diff --git a/tests/testutils/repo/bzr.py b/tests/testutils/repo/bzr.py index 53bacad17..8b2f17844 100644 --- a/tests/testutils/repo/bzr.py +++ b/tests/testutils/repo/bzr.py @@ -3,21 +3,16 @@ import subprocess import pytest from buildstream.testing import Repo -from .. import site - - -BZR_ENV = { - "BZR_EMAIL": "Testy McTesterson <testy.mctesterson@example.com>" -} +from buildstream.testing._utils.site import BZR, BZR_ENV, HAVE_BZR class Bzr(Repo): def __init__(self, directory, subdir): - if not site.HAVE_BZR: + if not HAVE_BZR: pytest.skip("bzr is not available") super(Bzr, self).__init__(directory, subdir) - self.bzr = site.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 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 deleted file mode 100644 index ef315efd6..000000000 --- a/tests/testutils/site.py +++ /dev/null @@ -1,73 +0,0 @@ -# Some things resolved about the execution site, -# so we dont have to repeat this everywhere -# -import os -import subprocess -import sys -import platform - -from buildstream import _site, utils, ProgramNotFoundError -from buildstream._platform import Platform - -try: - BZR = utils.get_host_tool('bzr') - HAVE_BZR = True -except ProgramNotFoundError: - HAVE_BZR = False - -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: - HAVE_OSTREE_CLI = False - -try: - from bst_plugins_experimental.sources import _ostree # pylint: disable=unused-import - HAVE_OSTREE = True -except (ImportError, ValueError): - HAVE_OSTREE = False - -try: - utils.get_host_tool('bwrap') - HAVE_BWRAP = True - HAVE_BWRAP_JSON_STATUS = _site.get_bwrap_version() >= (0, 3, 2) -except ProgramNotFoundError: - HAVE_BWRAP = False - HAVE_BWRAP_JSON_STATUS = False - -try: - utils.get_host_tool('lzip') - HAVE_LZIP = True -except ProgramNotFoundError: - HAVE_LZIP = False - -try: - import arpy # pylint: disable=unused-import - HAVE_ARPY = True -except ImportError: - HAVE_ARPY = False - -IS_LINUX = os.getenv('BST_FORCE_BACKEND', sys.platform).startswith('linux') -IS_WSL = (IS_LINUX and 'Microsoft' in platform.uname().release) -IS_WINDOWS = (os.name == 'nt') - -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: - HAVE_SANDBOX = True -else: - HAVE_SANDBOX = False - -MACHINE_ARCH = Platform.get_host_arch() |