summaryrefslogtreecommitdiff
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorPhil Dawson <phil.dawson@codethink.co.uk>2019-04-18 17:34:35 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-04-26 13:26:26 +0000
commit956ae30d56693555dc19ff81cc6f2a8a3ffe6560 (patch)
tree621b6f231749fccec912390d82b28bb086f6d54c /tests/conftest.py
parent140a9eb9f4ce2c3547e9f61262460dcc34f758c2 (diff)
downloadbuildstream-956ae30d56693555dc19ff81cc6f2a8a3ffe6560.tar.gz
testing: make Integration cache fixture available in testing module
The cli_integration fixture provided in testing.runcli depends on the integration cache fixture. This was missed when cli_integration was originally exposed.
Diffstat (limited to 'tests/conftest.py')
-rwxr-xr-xtests/conftest.py53
1 files changed, 3 insertions, 50 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 9b8ff2414..31b86e301 100755
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -20,11 +20,12 @@
# Tristan Maat <tristan.maat@codethink.co.uk>
#
import os
-import shutil
-import tempfile
import pytest
from buildstream._platform.platform import Platform
+
from buildstream.testing import register_repo_kind, sourcetests_collection_hook
+from buildstream.testing.integration import integration_cache # pylint: disable=unused-import
+
from tests.testutils.repo.git import Git
from tests.testutils.repo.bzr import Bzr
@@ -69,54 +70,6 @@ def pytest_runtest_setup(item):
#################################################
-# integration_cache fixture #
-#################################################
-#
-# This is yielded by the `integration_cache` fixture
-#
-class IntegrationCache():
-
- def __init__(self, cache):
- self.root = os.path.abspath(cache)
- os.makedirs(cache, exist_ok=True)
-
- # Use the same sources every time
- self.sources = os.path.join(self.root, 'sources')
-
- # Create a temp directory for the duration of the test for
- # the artifacts directory
- try:
- self.cachedir = tempfile.mkdtemp(dir=self.root, prefix='cache-')
- except OSError as e:
- raise AssertionError("Unable to create test directory !") from e
-
-
-@pytest.fixture(scope='session')
-def integration_cache(request):
- # Set the cache dir to the INTEGRATION_CACHE variable, or the
- # default if that is not set.
- if 'INTEGRATION_CACHE' in os.environ:
- cache_dir = os.environ['INTEGRATION_CACHE']
- else:
- cache_dir = os.path.abspath('./integration-cache')
-
- cache = IntegrationCache(cache_dir)
-
- yield cache
-
- # Clean up the artifacts after each test run - we only want to
- # cache sources between runs
- try:
- shutil.rmtree(cache.cachedir)
- except FileNotFoundError:
- pass
- try:
- shutil.rmtree(os.path.join(cache.root, 'cas'))
- except FileNotFoundError:
- pass
-
-
-#################################################
# remote_services fixture #
#################################################
#