diff options
author | Benjamin Schubert <contact@benschubert.me> | 2020-10-11 12:46:25 +0000 |
---|---|---|
committer | Benjamin Schubert <contact@benschubert.me> | 2020-10-15 20:17:58 +0000 |
commit | c958d4c9bb15e689b13408599245e360f215df21 (patch) | |
tree | 541ed5db6b5a4e3c68247969a34868c5f8bcd37f | |
parent | 567a9be1a29cd528a8eabc6471566a09a3bbd853 (diff) | |
download | buildstream-bschubert/standardize-source-tests.tar.gz |
tests: Stop using the implicit source tests and explicitely run thembschubert/standardize-source-tests
This makes use of the new helper classes to generate the source tests,
making them explicit to run
-rwxr-xr-x | tests/conftest.py | 29 | ||||
-rw-r--r-- | tests/sources/bzr.py | 7 | ||||
-rw-r--r-- | tests/sources/git.py | 7 | ||||
-rw-r--r-- | tests/sources/tar.py | 8 | ||||
-rw-r--r-- | tests/sources/zip.py | 8 |
5 files changed, 27 insertions, 32 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index d79ad40b0..30888a3f7 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -21,10 +21,8 @@ # import os -import pkg_resources import pytest -from buildstream.testing import register_repo_kind, sourcetests_collection_hook from buildstream.testing._fixtures import ( # pylint: disable=unused-import default_thread_number, reset_global_node_state, @@ -33,12 +31,6 @@ from buildstream.testing._fixtures import ( # pylint: disable=unused-import 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 -from tests.testutils.repo.tar import Tar -from tests.testutils.repo.zip import Zip - - # # This file is loaded by pytest, we use it to add a custom # `--integration` option to our test suite, and to install @@ -130,27 +122,6 @@ def remote_services(request): ################################################# -# Setup for templated source tests # -################################################# -register_repo_kind("git", Git, None) -register_repo_kind("bzr", Bzr, None) -register_repo_kind("tar", Tar, None) -register_repo_kind("zip", Zip, None) - - -# This hook enables pytest to collect the templated source tests from -# buildstream.testing -def pytest_sessionstart(session): - if session.config.getvalue("plugins"): - # Enable all plugins that implement the 'buildstream.tests.source_plugins' hook - for entrypoint in pkg_resources.iter_entry_points("buildstream.tests.source_plugins"): - module = entrypoint.load() - module.register_sources() - - sourcetests_collection_hook(session) - - -################################################# # Isolated environment # ################################################# @pytest.fixture(scope="session", autouse=True) diff --git a/tests/sources/bzr.py b/tests/sources/bzr.py index 37e6dc343..52def6675 100644 --- a/tests/sources/bzr.py +++ b/tests/sources/bzr.py @@ -5,7 +5,7 @@ import os import pytest from buildstream.testing import cli # pylint: disable=unused-import -from buildstream.testing import generate_element +from buildstream.testing import generate_element, SourceTests from buildstream.testing._utils.site import HAVE_BZR from tests.testutils.repo.bzr import Bzr @@ -13,6 +13,11 @@ from tests.testutils.repo.bzr import Bzr DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "bzr") +class TestBzrSource(SourceTests): + KIND = "bzr" + REPO = Bzr + + @pytest.mark.skipif(HAVE_BZR is False, reason="bzr is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR)) def test_fetch_checkout(cli, tmpdir, datafiles): diff --git a/tests/sources/git.py b/tests/sources/git.py index 22b87ea1c..79d988697 100644 --- a/tests/sources/git.py +++ b/tests/sources/git.py @@ -34,13 +34,20 @@ from buildstream.exceptions import ErrorDomain from buildstream.plugin import CoreWarnings from buildstream.testing import cli # pylint: disable=unused-import from buildstream.testing import generate_project, generate_element, load_yaml +from buildstream.testing import SourceTests from buildstream.testing._utils.site import HAVE_GIT, HAVE_OLD_GIT from tests.testutils.repo.git import Git + DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "git",) +class TestGitSource(SourceTests): + KIND = "git" + REPO = Git + + @pytest.mark.skipif(HAVE_GIT is False, reason="git is not available") @pytest.mark.datafiles(os.path.join(DATA_DIR, "template")) def test_fetch_bad_ref(cli, tmpdir, datafiles): diff --git a/tests/sources/tar.py b/tests/sources/tar.py index ed662dcd2..48d6eeafe 100644 --- a/tests/sources/tar.py +++ b/tests/sources/tar.py @@ -12,10 +12,11 @@ import pytest from buildstream import utils from buildstream.exceptions import ErrorDomain -from buildstream.testing import generate_project, generate_element +from buildstream.testing import generate_project, generate_element, SourceTests 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.repo.tar import Tar from . import list_dir_contents DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "tar",) @@ -41,6 +42,11 @@ def _assemble_tar_lz(workingdir, srcdir, dstfile): os.chdir(old_dir) +class TestTarSource(SourceTests): + KIND = "tar" + REPO = Tar + + # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, "no-ref")) def test_no_ref(cli, tmpdir, datafiles): diff --git a/tests/sources/zip.py b/tests/sources/zip.py index 201271fe0..9bcc009f7 100644 --- a/tests/sources/zip.py +++ b/tests/sources/zip.py @@ -7,9 +7,10 @@ import zipfile import pytest from buildstream.exceptions import ErrorDomain -from buildstream.testing import generate_project +from buildstream.testing import generate_project, SourceTests from buildstream.testing import cli # pylint: disable=unused-import from tests.testutils.file_server import create_file_server +from tests.testutils.repo.zip import Zip from . import list_dir_contents DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "zip",) @@ -27,6 +28,11 @@ def _assemble_zip(workingdir, dstfile): os.chdir(old_dir) +class TestZipSource(SourceTests): + KIND = "zip" + REPO = Zip + + # Test that without ref, consistency is set appropriately. @pytest.mark.datafiles(os.path.join(DATA_DIR, "no-ref")) def test_no_ref(cli, tmpdir, datafiles): |