Commit 16a28c03 authored by Phil Dawson's avatar Phil Dawson

Make templated source tests available in buildstream.plugintestutils

parent c30f4a56
......@@ -6,6 +6,9 @@ include MAINTAINERS
include NEWS
include README.rst
# Data files required by BuildStream's generic source tests
recursive-include buildstream/plugintestutils/_sourcetests/project *
# Documentation package includes
include doc/Makefile
include doc/badges.py
......
......@@ -15,8 +15,9 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <http://www.gnu.org/licenses/>.
import os
from collections import OrderedDict
from . import _sourcetests
from .repo import Repo
from .runcli import cli, cli_integration, cli_remote_execution
......@@ -89,5 +90,5 @@ def sourcetests_collection_hook(session):
# Add the location of the source tests to the session's
# python_files config. Without this, pytest may filter out these
# tests during collection.
session.config.addinivalue_line("python_files", os.path.join(SOURCE_TESTS_PATH, "/**.py"))
session.config.addinivalue_line("python_files", os.path.join(SOURCE_TESTS_PATH, "*.py"))
session.config.args.append(SOURCE_TESTS_PATH)
......@@ -22,13 +22,10 @@
import os
import pytest
from .._utils import generate_junction
from buildstream.plugintestutils import create_repo, ALL_REPO_KINDS
from tests.frontend import configure_project
from buildstream.plugintestutils import cli # pylint: disable=unused-import
from buildstream import _yaml
from .._utils import generate_junction, configure_project
from .. import create_repo, ALL_REPO_KINDS
from .. import cli # pylint: disable=unused-import
# Project directory
TOP_DIR = os.path.dirname(os.path.realpath(__file__))
......
......@@ -22,12 +22,11 @@
import os
import pytest
from .._utils import generate_junction
from buildstream.plugintestutils import create_repo, ALL_REPO_KINDS
from buildstream.plugintestutils import cli # pylint: disable=unused-import
from buildstream import _yaml
from buildstream._exceptions import ErrorDomain
from .._utils import generate_junction
from .. import create_repo, ALL_REPO_KINDS
from .. import cli # pylint: disable=unused-import
# Project directory
TOP_DIR = os.path.dirname(os.path.realpath(__file__))
......
......@@ -22,11 +22,10 @@
import os
import pytest
from .._utils.site import HAVE_SANDBOX
from buildstream.plugintestutils import create_repo, ALL_REPO_KINDS
from buildstream.plugintestutils import cli # pylint: disable=unused-import
from buildstream import _yaml
from .._utils.site import HAVE_SANDBOX
from .. import create_repo, ALL_REPO_KINDS
from .. import cli # pylint: disable=unused-import
# Project directory
TOP_DIR = os.path.dirname(os.path.realpath(__file__))
......
......@@ -22,14 +22,11 @@
import os
import pytest
from tests.frontend import configure_project
from .._utils import generate_junction
from buildstream.plugintestutils import create_repo, ALL_REPO_KINDS
from buildstream.plugintestutils import cli # pylint: disable=unused-import
from buildstream import _yaml
from buildstream._exceptions import ErrorDomain
from .._utils import generate_junction, configure_project
from .. import create_repo, ALL_REPO_KINDS
from .. import cli # pylint: disable=unused-import
# Project directory
TOP_DIR = os.path.dirname(os.path.realpath(__file__))
......
......@@ -22,11 +22,10 @@
import os
import pytest
from .._utils import generate_junction
from buildstream.plugintestutils import create_repo, ALL_REPO_KINDS
from buildstream.plugintestutils import cli # pylint: disable=unused-import
from buildstream import _yaml
from .._utils import generate_junction
from .. import create_repo, ALL_REPO_KINDS
from .. import cli # pylint: disable=unused-import
# Project directory
TOP_DIR = os.path.dirname(os.path.realpath(__file__))
......
......@@ -23,9 +23,9 @@ import os
import shutil
import pytest
from buildstream.plugintestutils import create_repo, ALL_REPO_KINDS
from buildstream.plugintestutils import cli # pylint: disable=unused-import
from buildstream import _yaml
from .. import create_repo, ALL_REPO_KINDS
from .. import cli # pylint: disable=unused-import
# Project directory
TOP_DIR = os.path.dirname(os.path.realpath(__file__))
......
import os
from buildstream import _yaml
from .junction import generate_junction
def configure_project(path, config):
config['name'] = 'test'
config['element-path'] = 'elements'
_yaml.dump(config, os.path.join(path, 'project.conf'))
import subprocess
import pytest
from .._utils.site import HAVE_GIT, GIT, GIT_ENV
from buildstream.plugintestutils import Repo
from buildstream import _yaml
from .. import Repo
from .site import HAVE_GIT, GIT, GIT_ENV
# generate_junction()
......
......@@ -323,6 +323,7 @@ setup(name='BuildStream',
packages=find_packages(exclude=('tests', 'tests.*')),
package_data={'buildstream': ['plugins/*/*.py', 'plugins/*/*.yaml',
'data/*.yaml', 'data/*.sh.in']},
include_package_data=True,
data_files=[
# This is a weak attempt to integrate with the user nicely,
# installing things outside of the python package itself with pip is
......
#!/usr/bin/env python3
#
# Copyright (C) 2018 Codethink Limited
# Copyright (C) 2019 Bloomberg Finance LLP
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
......@@ -23,6 +24,14 @@ import shutil
import tempfile
import pytest
from buildstream._platform.platform import Platform
from buildstream.plugintestutils import register_repo_kind, sourcetests_collection_hook
from tests.testutils.repo.git import Git
from tests.testutils.repo.bzr import Bzr
from tests.testutils.repo.ostree import OSTree
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
......@@ -155,3 +164,19 @@ def clean_platform_cache():
@pytest.fixture(autouse=True)
def ensure_platform_cache_is_clean():
clean_platform_cache()
#################################################
# Setup for templated source tests #
#################################################
register_repo_kind('git', Git)
register_repo_kind('bzr', Bzr)
register_repo_kind('ostree', OSTree)
register_repo_kind('tar', Tar)
register_repo_kind('zip', Zip)
# This hook enables pytest to collect the templated source tests from
# buildstream.plugintestutils
def pytest_sessionstart(session):
sourcetests_collection_hook(session)
import os
from buildstream.plugintestutils import register_repo_kind
from tests.testutils.repo.git import Git
from tests.testutils.repo.bzr import Bzr
from tests.testutils.repo.ostree import OSTree
from tests.testutils.repo.tar import Tar
from tests.testutils.repo.zip import Zip
register_repo_kind('git', Git)
register_repo_kind('bzr', Bzr)
register_repo_kind('ostree', OSTree)
register_repo_kind('tar', Tar)
register_repo_kind('zip', Zip)
def list_dir_contents(srcdir):
contents = set()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment