You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:35:47 UTC
[buildstream] 15/15: tests: Stop using the implicit source tests
and explicitely run them
This is an automated email from the ASF dual-hosted git repository.
not-in-ldap pushed a commit to branch bschubert/standardize-source-tests
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit c958d4c9bb15e689b13408599245e360f215df21
Author: Benjamin Schubert <co...@benschubert.me>
AuthorDate: Sun Oct 11 12:46:25 2020 +0000
tests: Stop using the implicit source tests and explicitely run them
This makes use of the new helper classes to generate the source tests,
making them explicit to run
---
tests/conftest.py | 29 -----------------------------
tests/sources/bzr.py | 7 ++++++-
tests/sources/git.py | 7 +++++++
tests/sources/tar.py | 8 +++++++-
tests/sources/zip.py | 8 +++++++-
5 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/tests/conftest.py b/tests/conftest.py
index d79ad40..30888a3 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 37e6dc3..52def66 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 22b87ea..79d9886 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 ed662dc..48d6eea 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 201271f..9bcc009 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):