You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:46:24 UTC
[buildstream] branch bschubert/test-plugins created (now 0a33c91)
This is an automated email from the ASF dual-hosted git repository.
root pushed a change to branch bschubert/test-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git.
at 0a33c91 pip.py: Remove the pip element, it is in experimental
This branch includes the following new commits:
new 47da03d conftest.py: Allow running tests using external plugins with --plugins
new 0a33c91 pip.py: Remove the pip element, it is in experimental
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[buildstream] 02/02: pip.py: Remove the pip element,
it is in experimental
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
root pushed a commit to branch bschubert/test-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 0a33c91c58a77b3293ede803748ec10d9070e936
Author: Benjamin Schubert <co...@benschubert.me>
AuthorDate: Fri May 8 20:10:25 2020 +0100
pip.py: Remove the pip element, it is in experimental
The pip element was copied already to bst-plugins-experimental.
We don't need to have two copies of it.
---
doc/source/core_plugins.rst | 1 -
src/buildstream/plugins/elements/pip.py | 51 -------------
src/buildstream/plugins/elements/pip.yaml | 36 ---------
tests/integration/pip_element.py | 117 ------------------------------
4 files changed, 205 deletions(-)
diff --git a/doc/source/core_plugins.rst b/doc/source/core_plugins.rst
index e788936..b407286 100644
--- a/doc/source/core_plugins.rst
+++ b/doc/source/core_plugins.rst
@@ -32,7 +32,6 @@ Build elements
elements/manual
elements/autotools
- elements/pip
.. _plugins_sources:
diff --git a/src/buildstream/plugins/elements/pip.py b/src/buildstream/plugins/elements/pip.py
deleted file mode 100644
index 5f805f4..0000000
--- a/src/buildstream/plugins/elements/pip.py
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Copyright (C) 2017 Mathieu Bridon
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# 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/>.
-#
-# Authors:
-# Mathieu Bridon <bo...@daitauha.fr>
-
-"""
-pip - Pip build element
-=======================
-A :mod:`BuildElement <buildstream.buildelement>` implementation for installing
-Python modules with pip
-
-The pip default configuration:
- .. literalinclude:: ../../../src/buildstream/plugins/elements/pip.yaml
- :language: yaml
-
-See :ref:`built-in functionality documentation <core_buildelement_builtins>` for
-details on common configuration options for build elements.
-"""
-
-from buildstream import BuildElement, SandboxFlags
-
-
-# Element implementation for the 'pip' kind.
-class PipElement(BuildElement):
- # pylint: disable=attribute-defined-outside-init
-
- BST_MIN_VERSION = "2.0"
-
- # Enable command batching across prepare() and assemble()
- def configure_sandbox(self, sandbox):
- super().configure_sandbox(sandbox)
- self.batch_prepare_assemble(SandboxFlags.ROOT_READ_ONLY, collect=self.get_variable("install-root"))
-
-
-# Plugin entry point
-def setup():
- return PipElement
diff --git a/src/buildstream/plugins/elements/pip.yaml b/src/buildstream/plugins/elements/pip.yaml
deleted file mode 100644
index 294d4ad..0000000
--- a/src/buildstream/plugins/elements/pip.yaml
+++ /dev/null
@@ -1,36 +0,0 @@
-# Pip default configurations
-
-variables:
-
- pip: pip
- pip-flags: |
- %{pip} install --no-deps --root=%{install-root} --prefix=%{prefix}
- pip-install-package: |
- %{pip-flags} %{conf-root}
- pip-download-dir: |
- .bst_pip_downloads
- pip-install-dependencies: |
- if [ -e %{pip-download-dir} ]; then %{pip-flags} %{pip-download-dir}/*; fi
-
-config:
-
- configure-commands: []
- build-commands: []
-
- # Commands for installing the software into a
- # destination folder
- #
- install-commands:
- - |
- %{pip-install-package}
- - |
- %{pip-install-dependencies}
-
- # Commands for stripping debugging information out of
- # installed binaries
- #
- strip-commands:
- - |
- %{strip-binaries}
- - |
- %{fix-pyc-timestamps}
diff --git a/tests/integration/pip_element.py b/tests/integration/pip_element.py
deleted file mode 100644
index bfc4f80..0000000
--- a/tests/integration/pip_element.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# Pylint doesn't play well with fixtures and dependency injection from pytest
-# pylint: disable=redefined-outer-name
-
-import os
-
-import pytest
-
-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
-
-
-pytestmark = pytest.mark.integration
-
-
-DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
-
-
-@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
-def test_pip_build(cli, datafiles):
- project = str(datafiles)
- checkout = os.path.join(cli.directory, "checkout")
- element_path = os.path.join(project, "elements")
- element_name = "pip/hello.bst"
-
- element = {
- "kind": "pip",
- "variables": {"pip": "pip3"},
- "depends": [{"filename": "base.bst"}],
- "sources": [
- {
- "kind": "tar",
- "url": "file://{}/files/hello.tar.xz".format(project),
- "ref": "ad96570b552498807abec33c06210bf68378d854ced6753b77916c5ed517610d",
- }
- ],
- }
- os.makedirs(os.path.dirname(os.path.join(element_path, element_name)), exist_ok=True)
- _yaml.roundtrip_dump(element, os.path.join(element_path, element_name))
-
- result = cli.run(project=project, args=["build", element_name])
- assert result.exit_code == 0
-
- result = cli.run(project=project, args=["artifact", "checkout", element_name, "--directory", checkout])
- assert result.exit_code == 0
-
- assert_contains(checkout, ["/usr", "/usr/lib", "/usr/bin", "/usr/bin/hello", "/usr/lib/python3.6"])
-
-
-# Test running an executable built with pip
-@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
-def test_pip_run(cli, datafiles):
- # Create and build our test element
- test_pip_build(cli, datafiles)
-
- project = str(datafiles)
- element_name = "pip/hello.bst"
-
- result = cli.run(project=project, args=["shell", element_name, "/usr/bin/hello"])
- assert result.exit_code == 0
- assert result.output == "Hello, world!\n"
-
-
-@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
-def test_pip_element_should_install_pip_deps(cli, datafiles, setup_pypi_repo):
- project = str(datafiles)
- elements_path = os.path.join(project, "elements")
- element_name = "pip/hello.bst"
-
- # check that exotically named packages are imported correctly
- myreqs_packages = "alohalib"
- dependencies = ["app2", "app.3", "app-4", "app_5", "app.no.6", "app-no-7", "app_no_8"]
- mock_packages = {myreqs_packages: {package: {} for package in dependencies}}
-
- # set up directories
- pypi_repo = os.path.join(project, "files", "pypi-repo")
- os.makedirs(pypi_repo, exist_ok=True)
- os.makedirs(os.path.dirname(os.path.join(elements_path, element_name)), exist_ok=True)
- setup_pypi_repo(mock_packages, pypi_repo)
-
- # create pip element
- element = {
- "kind": "pip",
- "variables": {"pip": "pip3"},
- "depends": [{"filename": "base.bst"}],
- "sources": [
- {
- "kind": "tar",
- "url": "file://{}/files/hello.tar.xz".format(project),
- # FIXME: remove hardcoded ref once issue #1010 is closed
- "ref": "ad96570b552498807abec33c06210bf68378d854ced6753b77916c5ed517610d",
- },
- {"kind": "pip", "url": "file://{}".format(os.path.realpath(pypi_repo)), "packages": [myreqs_packages],},
- ],
- }
- _yaml.roundtrip_dump(element, os.path.join(elements_path, element_name))
-
- result = cli.run(project=project, args=["source", "track", element_name])
- assert result.exit_code == 0
-
- result = cli.run(project=project, args=["build", element_name])
- assert result.exit_code == 0
-
- # get installed packages in sandbox
- installed_packages = set(
- cli.run(project=project, args=["shell", element_name, "pip3", "freeze"]).output.split("\n")
- )
- # compare with packages that are expected to be installed
- pip_source_packages = {package.replace("_", "-") + "==0.1" for package in dependencies + [myreqs_packages]}
- assert pip_source_packages.issubset(installed_packages)
[buildstream] 01/02: conftest.py: Allow running tests using
external plugins with --plugins
Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
root pushed a commit to branch bschubert/test-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 47da03ddc7572842d5b517d9a6b1f4c39c9da953
Author: bschubert15 <bs...@bloomberg.net>
AuthorDate: Fri Apr 17 09:42:04 2020 +0100
conftest.py: Allow running tests using external plugins with --plugins
This introduces a `pytest.mark.plugins` marker that signifies that
a test requires external plugins to run, and will only run them if
specifying `--plugins` on the pytest invocation.
---
setup.cfg | 1 +
src/buildstream/testing/_sourcetests/__init__.py | 4 ++++
tests/conftest.py | 7 +++++--
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/setup.cfg b/setup.cfg
index 8f095fa..83c381b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -18,6 +18,7 @@ markers =
datafiles: data files for tests
integration: run test only if --integration option is specified
remoteexecution: run test only if --remote-execution option is specified
+ plugins: run test only if --plugins option is specified
xfail_strict=True
[mypy]
diff --git a/src/buildstream/testing/_sourcetests/__init__.py b/src/buildstream/testing/_sourcetests/__init__.py
index e69de29..1b8ab40 100644
--- a/src/buildstream/testing/_sourcetests/__init__.py
+++ b/src/buildstream/testing/_sourcetests/__init__.py
@@ -0,0 +1,4 @@
+import pytest
+
+# All source tests are plugin tests
+pytestmark = pytest.mark.plugins
diff --git a/tests/conftest.py b/tests/conftest.py
index 8d33fa0..1d36373 100755
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -70,8 +70,11 @@ def pytest_runtest_setup(item):
# With --plugins only run plugins tests
if item.config.getvalue("plugins"):
- if not item.get_closest_marker("generic_source_test"):
- pytest.skip("Skipping not generic source test")
+ if not item.get_closest_marker("plugins"):
+ pytest.skip("Skipping tests that are not marked as requiring external plugins")
+ else:
+ if item.get_closest_marker("plugins"):
+ pytest.skip("Skipping tests that are marked as requiring external plugins")
#################################################