You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2021/02/04 07:49:10 UTC

[buildstream] branch coldtom/external-plugins created (now 94e9cc5)

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a change to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 94e9cc5  Add external plugin tests to CI

This branch includes the following new commits:

     new 1aae25a  Tests: Remove bst-plugins-experimental dependency
     new dcb6531  tests: Add a basic plugin to test variables
     new ea37496  Get plugins to test in bst CI
     new 74d3222  tests: Move standard workspace test to sourcetests
     new 509fcc1  tests: Remove some ostree stuff
     new 7ed843d  Add tox env for external standard plugin tests
     new c21fdd5  Remove integration tests for moved plugins
     new 94e9cc5  Add external plugin tests to CI

The 8 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/08: tests: Add a basic plugin to test variables

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit dcb65313605dee2efe7e83a9dcb059c9a88a983b
Author: Thomas Coldrick <th...@codethink.co.uk>
AuthorDate: Thu Sep 12 15:40:48 2019 +0100

    tests: Add a basic plugin to test variables
    
    As we're moving all plugins out of this repo, but we still should
    probably test that variables can be loaded from defaults and overrided
    correctly, I've added a very basic test plugin to handle this. It's
    essentially just a BuildElement, like autotools etc, but with basic
    variables to check if they're loaded.
---
 setup.cfg                                          |  8 ++++++-
 tests/format/variables.py                          |  2 ++
 tests/format/variables/defaults/plugins/test.py    | 18 ++++++++++++++
 tests/format/variables/defaults/plugins/test.yaml  | 28 ++++++++++++++++++++++
 tests/format/variables/defaults/project.conf       |  6 +++++
 tests/format/variables/defaults/test.bst           |  2 ++
 tests/format/variables/overrides/plugins/test.py   | 18 ++++++++++++++
 tests/format/variables/overrides/plugins/test.yaml | 28 ++++++++++++++++++++++
 tests/format/variables/overrides/project.conf      |  5 ++++
 tests/format/variables/overrides/test.bst          |  4 ++++
 10 files changed, 118 insertions(+), 1 deletion(-)

diff --git a/setup.cfg b/setup.cfg
index 2264a31..500a415 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -12,7 +12,13 @@ test=pytest
 
 [tool:pytest]
 addopts = --verbose --basetemp ./tmp --durations=20
-norecursedirs = tests/integration/project integration-cache tmp __pycache__ .eggs
+norecursedirs =
+    tests/integration/project
+    tests/format/variables
+    integration-cache
+    tmp
+    __pycache__
+    .eggs
 python_files = tests/*/*.py
 env =
     D:BST_TEST_SUITE=True
diff --git a/tests/format/variables.py b/tests/format/variables.py
index 5c4c94b..177e518 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -31,6 +31,7 @@ def print_warning(msg):
 ###############################################################
 @pytest.mark.parametrize("target,varname,expected", [
     ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/buildstream-install\" install"),
+    ('test.bst', 'configure', "foo")
 ])
 @pytest.mark.datafiles(os.path.join(DATA_DIR, 'defaults'))
 def test_defaults(cli, datafiles, target, varname, expected):
@@ -48,6 +49,7 @@ def test_defaults(cli, datafiles, target, varname, expected):
 ################################################################
 @pytest.mark.parametrize("target,varname,expected", [
     ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/custom/install/root\" install"),
+    ('test.bst', 'configure', "quuz")
 ])
 @pytest.mark.datafiles(os.path.join(DATA_DIR, 'overrides'))
 def test_overrides(cli, datafiles, target, varname, expected):
diff --git a/tests/format/variables/defaults/plugins/test.py b/tests/format/variables/defaults/plugins/test.py
new file mode 100644
index 0000000..0d793dd
--- /dev/null
+++ b/tests/format/variables/defaults/plugins/test.py
@@ -0,0 +1,18 @@
+from buildstream import BuildElement, SandboxFlags
+
+
+# Element implementation for the 'test' kind.
+class TestElement(BuildElement):
+    # Supports virtual directories (required for remote execution)
+    BST_VIRTUAL_DIRECTORY = True
+
+    # 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 TestElement
diff --git a/tests/format/variables/defaults/plugins/test.yaml b/tests/format/variables/defaults/plugins/test.yaml
new file mode 100644
index 0000000..432e23e
--- /dev/null
+++ b/tests/format/variables/defaults/plugins/test.yaml
@@ -0,0 +1,28 @@
+# Autotools default configurations
+
+variables:
+
+  configure: foo
+  make: bar
+  make-install: baz
+
+config:
+
+  # Commands for configuring the software
+  #
+  configure-commands:
+  - |
+    %{configure}
+
+  # Commands for building the software
+  #
+  build-commands:
+  - |
+    %{make}
+
+  # Commands for installing the software into a
+  # destination folder
+  #
+  install-commands:
+  - |
+    %{make-install}
diff --git a/tests/format/variables/defaults/project.conf b/tests/format/variables/defaults/project.conf
index 2027cc2..4c1894d 100644
--- a/tests/format/variables/defaults/project.conf
+++ b/tests/format/variables/defaults/project.conf
@@ -1,3 +1,9 @@
 # Basic project configuration that doesnt override anything
 #
 name: pony
+
+plugins:
+- origin: local
+  path: plugins
+  elements:
+    test: 0
diff --git a/tests/format/variables/defaults/test.bst b/tests/format/variables/defaults/test.bst
new file mode 100644
index 0000000..943eac3
--- /dev/null
+++ b/tests/format/variables/defaults/test.bst
@@ -0,0 +1,2 @@
+kind: test
+description: Some kinda test element
diff --git a/tests/format/variables/overrides/plugins/test.py b/tests/format/variables/overrides/plugins/test.py
new file mode 100644
index 0000000..0d793dd
--- /dev/null
+++ b/tests/format/variables/overrides/plugins/test.py
@@ -0,0 +1,18 @@
+from buildstream import BuildElement, SandboxFlags
+
+
+# Element implementation for the 'test' kind.
+class TestElement(BuildElement):
+    # Supports virtual directories (required for remote execution)
+    BST_VIRTUAL_DIRECTORY = True
+
+    # 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 TestElement
diff --git a/tests/format/variables/overrides/plugins/test.yaml b/tests/format/variables/overrides/plugins/test.yaml
new file mode 100644
index 0000000..432e23e
--- /dev/null
+++ b/tests/format/variables/overrides/plugins/test.yaml
@@ -0,0 +1,28 @@
+# Autotools default configurations
+
+variables:
+
+  configure: foo
+  make: bar
+  make-install: baz
+
+config:
+
+  # Commands for configuring the software
+  #
+  configure-commands:
+  - |
+    %{configure}
+
+  # Commands for building the software
+  #
+  build-commands:
+  - |
+    %{make}
+
+  # Commands for installing the software into a
+  # destination folder
+  #
+  install-commands:
+  - |
+    %{make-install}
diff --git a/tests/format/variables/overrides/project.conf b/tests/format/variables/overrides/project.conf
index 2027cc2..2fe3a8f 100644
--- a/tests/format/variables/overrides/project.conf
+++ b/tests/format/variables/overrides/project.conf
@@ -1,3 +1,8 @@
 # Basic project configuration that doesnt override anything
 #
 name: pony
+plugins:
+- origin: local
+  path: plugins
+  elements:
+    test: 0
diff --git a/tests/format/variables/overrides/test.bst b/tests/format/variables/overrides/test.bst
new file mode 100644
index 0000000..7094c6c
--- /dev/null
+++ b/tests/format/variables/overrides/test.bst
@@ -0,0 +1,4 @@
+kind: test
+description: Some kinda test element
+variables:
+  configure: quuz


[buildstream] 01/08: Tests: Remove bst-plugins-experimental dependency

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 1aae25a9c15fed48bd12edc395b4cbf49f298860
Author: Thomas Coldrick <th...@codethink.co.uk>
AuthorDate: Thu Sep 12 15:25:17 2019 +0100

    Tests: Remove bst-plugins-experimental dependency
    
    This stops the tests from being interlinked for BuildStream itself.
---
 tests/format/variables.py                        | 18 ------------------
 tests/format/variables/defaults/cmake.bst        |  2 --
 tests/format/variables/defaults/distutils.bst    |  2 --
 tests/format/variables/defaults/makemaker.bst    |  2 --
 tests/format/variables/defaults/modulebuild.bst  |  2 --
 tests/format/variables/defaults/project.conf     | 10 ----------
 tests/format/variables/defaults/qmake.bst        |  2 --
 tests/format/variables/overrides/cmake.bst       |  7 -------
 tests/format/variables/overrides/distutils.bst   |  6 ------
 tests/format/variables/overrides/makemaker.bst   |  6 ------
 tests/format/variables/overrides/modulebuild.bst |  6 ------
 tests/format/variables/overrides/project.conf    |  9 ---------
 tests/format/variables/overrides/qmake.bst       |  6 ------
 tox.ini                                          |  1 -
 14 files changed, 79 deletions(-)

diff --git a/tests/format/variables.py b/tests/format/variables.py
index 4610e03..5c4c94b 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -31,15 +31,6 @@ def print_warning(msg):
 ###############################################################
 @pytest.mark.parametrize("target,varname,expected", [
     ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/buildstream-install\" install"),
-    ('cmake.bst', 'cmake',
-     "cmake -B_builddir -H\".\" -G\"Unix Makefiles\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/usr\" \\\n" +
-     "-DCMAKE_INSTALL_LIBDIR:PATH=\"lib\""),
-    ('distutils.bst', 'python-install',
-     "python3 ./setup.py install --prefix \"/usr\" \\\n" +
-     "--root \"/buildstream-install\""),
-    ('makemaker.bst', 'configure', "perl Makefile.PL PREFIX=/buildstream-install/usr"),
-    ('modulebuild.bst', 'configure', "perl Build.PL --prefix \"/buildstream-install/usr\""),
-    ('qmake.bst', 'make-install', "make -j1 INSTALL_ROOT=\"/buildstream-install\" install"),
 ])
 @pytest.mark.datafiles(os.path.join(DATA_DIR, 'defaults'))
 def test_defaults(cli, datafiles, target, varname, expected):
@@ -57,15 +48,6 @@ def test_defaults(cli, datafiles, target, varname, expected):
 ################################################################
 @pytest.mark.parametrize("target,varname,expected", [
     ('autotools.bst', 'make-install', "make -j1 DESTDIR=\"/custom/install/root\" install"),
-    ('cmake.bst', 'cmake',
-     "cmake -B_builddir -H\".\" -G\"Ninja\" " + "-DCMAKE_INSTALL_PREFIX:PATH=\"/opt\" \\\n" +
-     "-DCMAKE_INSTALL_LIBDIR:PATH=\"lib\""),
-    ('distutils.bst', 'python-install',
-     "python3 ./setup.py install --prefix \"/opt\" \\\n" +
-     "--root \"/custom/install/root\""),
-    ('makemaker.bst', 'configure', "perl Makefile.PL PREFIX=/custom/install/root/opt"),
-    ('modulebuild.bst', 'configure', "perl Build.PL --prefix \"/custom/install/root/opt\""),
-    ('qmake.bst', 'make-install', "make -j1 INSTALL_ROOT=\"/custom/install/root\" install"),
 ])
 @pytest.mark.datafiles(os.path.join(DATA_DIR, 'overrides'))
 def test_overrides(cli, datafiles, target, varname, expected):
diff --git a/tests/format/variables/defaults/cmake.bst b/tests/format/variables/defaults/cmake.bst
deleted file mode 100644
index 4e7db66..0000000
--- a/tests/format/variables/defaults/cmake.bst
+++ /dev/null
@@ -1,2 +0,0 @@
-kind: cmake
-description: Some kinda cmake element
diff --git a/tests/format/variables/defaults/distutils.bst b/tests/format/variables/defaults/distutils.bst
deleted file mode 100644
index 2354bea..0000000
--- a/tests/format/variables/defaults/distutils.bst
+++ /dev/null
@@ -1,2 +0,0 @@
-kind: distutils
-description: Some kinda distutils element
diff --git a/tests/format/variables/defaults/makemaker.bst b/tests/format/variables/defaults/makemaker.bst
deleted file mode 100644
index 2205cec..0000000
--- a/tests/format/variables/defaults/makemaker.bst
+++ /dev/null
@@ -1,2 +0,0 @@
-kind: makemaker
-description: Some kinda makemaker element
diff --git a/tests/format/variables/defaults/modulebuild.bst b/tests/format/variables/defaults/modulebuild.bst
deleted file mode 100644
index 5b5e9b9..0000000
--- a/tests/format/variables/defaults/modulebuild.bst
+++ /dev/null
@@ -1,2 +0,0 @@
-kind: modulebuild
-description: Some kinda modulebuild element
diff --git a/tests/format/variables/defaults/project.conf b/tests/format/variables/defaults/project.conf
index 029f07c..2027cc2 100644
--- a/tests/format/variables/defaults/project.conf
+++ b/tests/format/variables/defaults/project.conf
@@ -1,13 +1,3 @@
 # Basic project configuration that doesnt override anything
 #
 name: pony
-
-plugins:
-- origin: pip
-  package-name: bst-plugins-experimental
-  elements:
-    cmake: 0
-    distutils: 0
-    makemaker: 0
-    modulebuild: 0
-    qmake: 0
diff --git a/tests/format/variables/defaults/qmake.bst b/tests/format/variables/defaults/qmake.bst
deleted file mode 100644
index 5320976..0000000
--- a/tests/format/variables/defaults/qmake.bst
+++ /dev/null
@@ -1,2 +0,0 @@
-kind: qmake
-description: Some kinda qmake element
diff --git a/tests/format/variables/overrides/cmake.bst b/tests/format/variables/overrides/cmake.bst
deleted file mode 100644
index ceea2bb..0000000
--- a/tests/format/variables/overrides/cmake.bst
+++ /dev/null
@@ -1,7 +0,0 @@
-kind: cmake
-description: Some kinda cmake element
-
-variables:
-  generator: Ninja
-  install-root: /custom/install/root
-  prefix: /opt
diff --git a/tests/format/variables/overrides/distutils.bst b/tests/format/variables/overrides/distutils.bst
deleted file mode 100644
index 624f775..0000000
--- a/tests/format/variables/overrides/distutils.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: distutils
-description: Some kinda distutils element
-
-variables:
-  install-root: /custom/install/root
-  prefix: /opt
diff --git a/tests/format/variables/overrides/makemaker.bst b/tests/format/variables/overrides/makemaker.bst
deleted file mode 100644
index faa5f36..0000000
--- a/tests/format/variables/overrides/makemaker.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: makemaker
-description: Some kinda makemaker element
-
-variables:
-  install-root: /custom/install/root
-  prefix: /opt
diff --git a/tests/format/variables/overrides/modulebuild.bst b/tests/format/variables/overrides/modulebuild.bst
deleted file mode 100644
index db50057..0000000
--- a/tests/format/variables/overrides/modulebuild.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: modulebuild
-description: Some kinda modulebuild element
-
-variables:
-  install-root: /custom/install/root
-  prefix: /opt
diff --git a/tests/format/variables/overrides/project.conf b/tests/format/variables/overrides/project.conf
index e4854a6..2027cc2 100644
--- a/tests/format/variables/overrides/project.conf
+++ b/tests/format/variables/overrides/project.conf
@@ -1,12 +1,3 @@
 # Basic project configuration that doesnt override anything
 #
 name: pony
-plugins:
-- origin: pip
-  package-name: bst-plugins-experimental
-  elements:
-    cmake: 0
-    distutils: 0
-    makemaker: 0
-    modulebuild: 0
-    qmake: 0
diff --git a/tests/format/variables/overrides/qmake.bst b/tests/format/variables/overrides/qmake.bst
deleted file mode 100644
index 5dff2c9..0000000
--- a/tests/format/variables/overrides/qmake.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: qmake
-description: Some kinda qmake element
-
-variables:
-  install-root: /custom/install/root
-  prefix: /opt
diff --git a/tox.ini b/tox.ini
index a00197d..309e0cc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -30,7 +30,6 @@ deps =
     py{35,36,37}: -rrequirements/requirements.txt
     py{35,36,37}: -rrequirements/dev-requirements.txt
     py{35,36,37}: -rrequirements/plugin-requirements.txt
-    git+https://gitlab.com/BuildStream/bst-plugins-experimental.git@5b004e5850ab0e987c00c681b2c768f6ae02586b
 
     # Only require coverage and pytest-cov when using it
     !nocover: -rrequirements/cov-requirements.txt


[buildstream] 06/08: Add tox env for external standard plugin tests

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 7ed843dabe76f038001a53b8e8e90a5955f82359
Author: Thomas Coldrick <th...@codethink.co.uk>
AuthorDate: Tue Sep 17 13:35:30 2019 +0100

    Add tox env for external standard plugin tests
    
    Adds tooling to define a list of external plugin repos in
    `requirements/external-requirements.yml` in a nice yaml format, which
    seemed the easiest way to sort out the potential config issues. The main
    thing is the addition of the `requirements/parse-external.py` script,
    which generates a list of package names and two requirements.txt files,
    one for fixed versions, one for master.
    
    It is assumed that `master` more means "test against a branch" and
    `fixed` means "test against a tag".
    
    Also adds tox environments to run these tests.
---
 requirements/external-fixed.txt        |  1 +
 requirements/external-master.txt       |  1 +
 requirements/external-requirements.yml |  6 +++++
 requirements/parse-external.py         | 49 ++++++++++++++++++++++++++++++++++
 tests/conftest.py                      | 22 +++++++++++----
 tox.ini                                | 24 ++++++-----------
 6 files changed, 82 insertions(+), 21 deletions(-)

diff --git a/requirements/external-fixed.txt b/requirements/external-fixed.txt
new file mode 100644
index 0000000..8160738
--- /dev/null
+++ b/requirements/external-fixed.txt
@@ -0,0 +1 @@
+git+https://gitlab.com/buildstream/bst-plugins-experimental.git@0.12.0#egg=bst_plugins_experimental[ostree]
diff --git a/requirements/external-master.txt b/requirements/external-master.txt
new file mode 100644
index 0000000..2d84de2
--- /dev/null
+++ b/requirements/external-master.txt
@@ -0,0 +1 @@
+git+https://gitlab.com/buildstream/bst-plugins-experimental.git@master#egg=bst_plugins_experimental[ostree]
diff --git a/requirements/external-requirements.yml b/requirements/external-requirements.yml
new file mode 100644
index 0000000..cf75357
--- /dev/null
+++ b/requirements/external-requirements.yml
@@ -0,0 +1,6 @@
+- package_name: bst_plugins_experimental
+  url: https://gitlab.com/buildstream/bst-plugins-experimental.git
+  branch: master
+  tag: 0.12.0
+  extras:
+  - ostree
diff --git a/requirements/parse-external.py b/requirements/parse-external.py
new file mode 100755
index 0000000..9df95a2
--- /dev/null
+++ b/requirements/parse-external.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+
+from enum import Enum
+from ruamel import yaml
+
+
+class PluginVersion(Enum):
+    MASTER = 0
+    FIXED = 1
+
+
+def load_file(filename):
+    with open(filename, 'r') as stream:
+        try:
+            return yaml.safe_load(stream)
+        except yaml.YAMLError as exc:
+            print(exc)
+
+
+def format_single_req(dep, version):
+    extras = ''
+    if 'extras' in dep.keys():
+        extras = ','.join(dep['extras'])
+
+    if version == PluginVersion.MASTER:
+        ref = 'master'
+        if 'branch' in dep.keys():
+            ref = dep['branch']
+    else:
+        ref = dep['tag']
+
+    return "git+{}@{}#egg={}[{}]\n".format(
+        dep['url'],
+        ref,
+        dep['package_name'],
+        extras)
+
+
+def write_requirements_file(filename, deps, version):
+    with open(filename, 'w') as f:
+        for dep in deps:
+            f.write(format_single_req(dep, version))
+
+
+if __name__ == '__main__':
+    deps = load_file('requirements/external-requirements.yml')
+
+    write_requirements_file('requirements/external-master.txt', deps, PluginVersion.MASTER)
+    write_requirements_file('requirements/external-fixed.txt', deps, PluginVersion.FIXED)
diff --git a/tests/conftest.py b/tests/conftest.py
index a1ca97f..079a763 100755
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -20,6 +20,7 @@
 #        Tristan Maat <tr...@codethink.co.uk>
 #
 import os
+import pkg_resources
 import pytest
 
 from buildstream.testing import register_repo_kind, sourcetests_collection_hook
@@ -51,8 +52,16 @@ def pytest_addoption(parser):
     parser.addoption('--remote-execution', action='store_true', default=False,
                      help='Run remote-execution tests only')
 
+    # This doesn't actually do anything at the moment, as we don't have standardised
+    # element tests
+    parser.addoption('--external-elements', action='store_true', default=False,
+                     help="Run standardised tests for external elements")
+
+    parser.addoption('--external-sources', action='store_true', default=False,
+                     help="Run standardised tests for external elements")
+
     parser.addoption('--external-plugins', action='store_true', default=False,
-                     help="Run standardised tests for external plugins")
+                     help="Run standardised tests for external elements and sources")
 
 
 def pytest_runtest_setup(item):
@@ -139,11 +148,14 @@ register_repo_kind('zip', Zip, None)
 # This hook enables pytest to collect the templated source tests from
 # buildstream.testing
 def pytest_sessionstart(session):
-    sourcetests_collection_hook(session)
+    # Register sources from external plugins, if option passed
+    if session.config.getvalue('external_plugins') or session.config.getvalue('external_sources'):
+        packages = {entrypoint.module_name.split('.')[0]
+                    for entrypoint in pkg_resources.iter_entry_points('buildstream.plugins')}
+        for package in packages:
+            __import__(package).testutils.register_sources()
 
-    if session.config.getvalue('external_plugins'):
-        import bst_plugins_experimental
-        bst_plugins_experimental.testutils.register_sources()
+    sourcetests_collection_hook(session)
 
 
 #################################################
diff --git a/tox.ini b/tox.ini
index ce36da9..2acf118 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,30 +15,26 @@ isolated_build = true
 usedevelop =
     # This is required by Cython in order to get coverage for cython files.
     py{35,36,37}-!nocover: True
-    plugins: True
 
 commands =
+    py{35,36,37}-plugins: python3 {toxinidir}/requirements/parse-external.py
+    py{35,36,37}-plugins-master: pip3 install -r {toxinidir}/requirements/external-master.txt
+    py{35,36,37}-plugins-fixed: pip3 install -r {toxinidir}/requirements/external-fixed.txt
+    py{35,36,37}-plugins: pytest --basetemp {envtmpdir} --external-plugins {posargs}
+
     # Running with coverage reporting enabled
-    py{35,36,37}-!nocover: pytest --basetemp {envtmpdir} --cov=buildstream --cov-config .coveragerc {posargs}
-    py{35,36,37}-!nocover: mkdir -p .coverage-reports
-    py{35,36,37}-!nocover: mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}
+    py{35,36,37}-!nocover-!plugins: pytest --basetemp {envtmpdir} --cov=buildstream --cov-config .coveragerc {posargs}
+    py{35,36,37}-!nocover-!plugins: mkdir -p .coverage-reports
+    py{35,36,37}-!nocover-!plugins: mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}
     # Running with coverage reporting disabled
     py{35,36,37}-nocover: pytest --basetemp {envtmpdir} {posargs}
 
-    plugins: pytest --basetemp {envtmpdir} --external-plugins {posargs}
-
    
 deps =
     py{35,36,37}: -rrequirements/requirements.txt
     py{35,36,37}: -rrequirements/dev-requirements.txt
     py{35,36,37}: -rrequirements/plugin-requirements.txt
     
-    plugins: -rrequirements/requirements.txt
-    plugins: -rrequirements/dev-requirements.txt
-    plugins: -rrequirements/plugin-requirements.txt
-    plugins: git+https://gitlab.com/buildstream/bst-plugins-experimental@coldtom/setup-py-improvements
-
-
     # Only require coverage and pytest-cov when using it
     py{35,36,37}-!nocover: -rrequirements/cov-requirements.txt
 passenv =
@@ -73,10 +69,6 @@ whitelist_externals =
     py{35,36,37}:
         mv
         mkdir
-    plugins:
-        rm
-        mv
-        git
 #
 # Coverage reporting
 #


[buildstream] 08/08: Add external plugin tests to CI

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 94e9cc542b3e8154706809e5dde54ff9e7235d31
Author: Thomas Coldrick <th...@codethink.co.uk>
AuthorDate: Fri Sep 20 11:46:23 2019 +0100

    Add external plugin tests to CI
    
    Runs external plugin tests on fedora 29 with allowed failure.
    
    At present this only tests against a branch, as there is tooling missing
    in bst-plugins-experimental, and there is no tag which would be
    compatible. In future there should be two targets, one testing plugins
    master and one testing the last tag.
---
 .gitlab-ci.yml | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ef31ad3..51e0f8c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -18,7 +18,7 @@ variables:
   INTEGRATION_CACHE: "${CI_PROJECT_DIR}/cache/integration-cache"
   PYTEST_ARGS: "--color=yes --integration -n 2"
   TEST_COMMAND: "tox -- ${PYTEST_ARGS}"
-  EXTERNAL_TESTS_COMMAND: "tox -e py{35,36,37}-external -- ${PYTEST_ARGS}"
+  EXTERNAL_TESTS_COMMAND: "tox -e py37-plugins-master -- ${PYTEST_ARGS}"
   COVERAGE_PREFIX: "${CI_JOB_NAME}."
 
 
@@ -44,7 +44,6 @@ variables:
 
   # Run the tests as a simple user to test for permission issues
   - su buildstream -c "${TEST_COMMAND}"
-  - su buildstream -c "${EXTERNAL_TESTS_COMMAND}"
 
   after_script:
   except:
@@ -195,6 +194,18 @@ tests-spawn-multiprocessing-start-method:
   variables:
     BST_FORCE_START_METHOD: "spawn"
 
+tests-external-plugins:
+  image: registry.gitlab.com/buildstream/buildstream-docker-images/testsuite-fedora:30-master-83237142
+  allow_failure: true
+  script:
+  - mkdir -p "${INTEGRATION_CACHE}"
+  - useradd -Um buildstream
+  - chown -R buildstream:buildstream .
+
+  # Run the tests as a simple user to test for permission issues
+  - su buildstream -c "${EXTERNAL_TESTS_COMMAND}"
+
+
 # Run type checkers
 mypy:
   stage: test


[buildstream] 07/08: Remove integration tests for moved plugins

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit c21fdd559356c88465eac352a302284f8495bf7e
Author: Thomas Coldrick <th...@codethink.co.uk>
AuthorDate: Fri Sep 20 10:09:37 2019 +0100

    Remove integration tests for moved plugins
---
 tests/integration/cmake.py                         |  68 ---------------------
 tests/integration/make.py                          |  52 ----------------
 .../project/elements/cmake/cmakeconfroothello.bst  |  15 -----
 .../project/elements/cmake/cmakehello.bst          |  10 ---
 .../project/elements/make/makehello.bst            |  10 ---
 tests/integration/project/files/cmakehello.tar.gz  | Bin 10240 -> 0 bytes
 tests/integration/project/files/makehello.tar.gz   | Bin 432 -> 0 bytes
 7 files changed, 155 deletions(-)

diff --git a/tests/integration/cmake.py b/tests/integration/cmake.py
deleted file mode 100644
index a0298c2..0000000
--- a/tests/integration/cmake.py
+++ /dev/null
@@ -1,68 +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.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
-
-
-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_cmake_build(cli, datafiles):
-    project = str(datafiles)
-    checkout = os.path.join(cli.directory, 'checkout')
-    element_name = 'cmake/cmakehello.bst'
-
-    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/bin', '/usr/bin/hello'])
-
-
-@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
-@pytest.mark.xfail(HAVE_SANDBOX == 'buildbox', reason='Not working with BuildBox')
-def test_cmake_confroot_build(cli, datafiles):
-    project = str(datafiles)
-    checkout = os.path.join(cli.directory, 'checkout')
-    element_name = 'cmake/cmakeconfroothello.bst'
-
-    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/bin', '/usr/bin/hello'])
-
-
-@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
-def test_cmake_run(cli, datafiles):
-    project = str(datafiles)
-    element_name = 'cmake/cmakehello.bst'
-
-    result = cli.run(project=project, args=['build', element_name])
-    assert result.exit_code == 0
-
-    result = cli.run(project=project, args=['shell', element_name, '/usr/bin/hello'])
-    assert result.exit_code == 0
-
-    assert result.output == """Hello World!
-This is hello.
-"""
diff --git a/tests/integration/make.py b/tests/integration/make.py
deleted file mode 100644
index 664e7ca..0000000
--- a/tests/integration/make.py
+++ /dev/null
@@ -1,52 +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.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
-
-
-pytestmark = pytest.mark.integration
-
-
-DATA_DIR = os.path.join(
-    os.path.dirname(os.path.realpath(__file__)),
-    "project"
-)
-
-
-# Test that a make build 'works' - we use the make sample
-# makehello project for this.
-@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
-def test_make_build(cli, datafiles):
-    project = str(datafiles)
-    checkout = os.path.join(cli.directory, 'checkout')
-    element_name = 'make/makehello.bst'
-
-    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/bin',
-                               '/usr/bin/hello'])
-
-
-# Test running an executable built with make
-@pytest.mark.datafiles(DATA_DIR)
-@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
-def test_make_run(cli, datafiles):
-    project = str(datafiles)
-    element_name = 'make/makehello.bst'
-
-    result = cli.run(project=project, args=['build', element_name])
-    assert result.exit_code == 0
-
-    result = cli.run(project=project, args=['shell', element_name, '/usr/bin/hello'])
-    assert result.exit_code == 0
-    assert result.output == 'Hello, world\n'
diff --git a/tests/integration/project/elements/cmake/cmakeconfroothello.bst b/tests/integration/project/elements/cmake/cmakeconfroothello.bst
deleted file mode 100644
index cd33dee..0000000
--- a/tests/integration/project/elements/cmake/cmakeconfroothello.bst
+++ /dev/null
@@ -1,15 +0,0 @@
-kind: cmake
-description: Cmake test
-
-depends:
-  - base.bst
-
-sources:
-  - kind: tar
-    directory: Source
-    url: project_dir:/files/cmakehello.tar.gz
-    ref: 508266f40dbc5875293bd24c4e50a9eb6b88cbacab742033f7b92f8c087b64e5
-
-variables:
-  conf-root: "%{build-root}/Source"
-  command-subdir: build
diff --git a/tests/integration/project/elements/cmake/cmakehello.bst b/tests/integration/project/elements/cmake/cmakehello.bst
deleted file mode 100644
index c5fe496..0000000
--- a/tests/integration/project/elements/cmake/cmakehello.bst
+++ /dev/null
@@ -1,10 +0,0 @@
-kind: cmake
-description: Cmake test
-
-depends:
-  - base.bst
-
-sources:
-  - kind: tar
-    url: project_dir:/files/cmakehello.tar.gz
-    ref: 508266f40dbc5875293bd24c4e50a9eb6b88cbacab742033f7b92f8c087b64e5
diff --git a/tests/integration/project/elements/make/makehello.bst b/tests/integration/project/elements/make/makehello.bst
deleted file mode 100644
index 4b5c5ac..0000000
--- a/tests/integration/project/elements/make/makehello.bst
+++ /dev/null
@@ -1,10 +0,0 @@
-kind: make
-description: make test
-
-depends:
-- base.bst
-
-sources:
-- kind: tar
-  url: project_dir:/files/makehello.tar.gz
-  ref: fd342a36503a0a0dd37b81ddb4d2b78bd398d912d813339e0de44a6b6c393b8e
diff --git a/tests/integration/project/files/cmakehello.tar.gz b/tests/integration/project/files/cmakehello.tar.gz
deleted file mode 100644
index 54d9505..0000000
Binary files a/tests/integration/project/files/cmakehello.tar.gz and /dev/null differ
diff --git a/tests/integration/project/files/makehello.tar.gz b/tests/integration/project/files/makehello.tar.gz
deleted file mode 100644
index d0edcb2..0000000
Binary files a/tests/integration/project/files/makehello.tar.gz and /dev/null differ


[buildstream] 05/08: tests: Remove some ostree stuff

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 509fcc12bf962b43c248702c3db09f6997fa72e2
Author: Thomas Coldrick <th...@codethink.co.uk>
AuthorDate: Tue Sep 17 13:33:44 2019 +0100

    tests: Remove some ostree stuff
---
 tests/sources/ostree/template/project.conf   | 2 --
 tests/sources/ostree/template/repofiles/file | 0
 2 files changed, 2 deletions(-)

diff --git a/tests/sources/ostree/template/project.conf b/tests/sources/ostree/template/project.conf
deleted file mode 100644
index afa0f54..0000000
--- a/tests/sources/ostree/template/project.conf
+++ /dev/null
@@ -1,2 +0,0 @@
-# Basic project
-name: foo
diff --git a/tests/sources/ostree/template/repofiles/file b/tests/sources/ostree/template/repofiles/file
deleted file mode 100644
index e69de29..0000000


[buildstream] 04/08: tests: Move standard workspace test to sourcetests

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 74d322263464f9fb0870326f694d8750f414e7e6
Author: Thomas Coldrick <th...@codethink.co.uk>
AuthorDate: Tue Sep 17 11:09:46 2019 +0100

    tests: Move standard workspace test to sourcetests
    
    As this test is parametised by the repo kinds from the _sourcetests, we
    should move it to be with them. As an additional motivation, not moving
    this means that these tests fail when we register external sources.
---
 src/buildstream/testing/_sourcetests/workspace.py | 58 +++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/src/buildstream/testing/_sourcetests/workspace.py b/src/buildstream/testing/_sourcetests/workspace.py
index dd7977e..299256e 100644
--- a/src/buildstream/testing/_sourcetests/workspace.py
+++ b/src/buildstream/testing/_sourcetests/workspace.py
@@ -158,3 +158,61 @@ def open_workspace(cli, tmpdir, datafiles, kind, track, suffix='', workspace_dir
 @pytest.mark.datafiles(DATA_DIR)
 def test_open(cli, tmpdir, datafiles, kind):
     open_workspace(cli, tmpdir, datafiles, kind, False)
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("kind", repo_kinds)
+@pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
+@pytest.mark.parametrize(
+    "from_workspace,guess_element",
+    [(False, False), (True, True), (True, False)],
+    ids=["project-no-guess", "workspace-guess", "workspace-no-guess"])
+def test_build(cli, tmpdir_factory, datafiles, kind, strict, from_workspace, guess_element):
+    tmpdir = tmpdir_factory.mktemp('')
+    element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False)
+    checkout = os.path.join(str(tmpdir), 'checkout')
+    args_dir = ['-C', workspace] if from_workspace else []
+    args_elm = [element_name] if not guess_element else []
+
+    # Modify workspace
+    shutil.rmtree(os.path.join(workspace, 'usr', 'bin'))
+    os.makedirs(os.path.join(workspace, 'etc'))
+    with open(os.path.join(workspace, 'etc', 'pony.conf'), 'w') as f:
+        f.write("PONY='pink'")
+
+    # Configure strict mode
+    strict_mode = True
+    if strict != 'strict':
+        strict_mode = False
+    cli.configure({
+        'projects': {
+            'test': {
+                'strict': strict_mode
+            }
+        }
+    })
+
+    # Build modified workspace
+    assert cli.get_element_state(project, element_name) == 'buildable'
+    key_1 = cli.get_element_key(project, element_name)
+    assert key_1 != "{:?<64}".format('')
+    result = cli.run(project=project, args=args_dir + ['build', *args_elm])
+    result.assert_success()
+    assert cli.get_element_state(project, element_name) == 'cached'
+    key_2 = cli.get_element_key(project, element_name)
+    assert key_2 != "{:?<64}".format('')
+
+    # workspace keys are not recalculated
+    assert key_1 == key_2
+
+    # Checkout the result
+    result = cli.run(project=project,
+                     args=args_dir + ['artifact', 'checkout', '--directory', checkout, *args_elm])
+    result.assert_success()
+
+    # Check that the pony.conf from the modified workspace exists
+    filename = os.path.join(checkout, 'etc', 'pony.conf')
+    assert os.path.exists(filename)
+
+    # Check that the original /usr/bin/hello is not in the checkout
+    assert not os.path.exists(os.path.join(checkout, 'usr', 'bin', 'hello'))


[buildstream] 03/08: Get plugins to test in bst CI

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch coldtom/external-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit ea374960a2bcd798f288ee030ebc4d627e94c582
Author: Thomas Coldrick <th...@codethink.co.uk>
AuthorDate: Mon Sep 16 16:30:35 2019 +0100

    Get plugins to test in bst CI
---
 tests/conftest.py |  7 +++++++
 tox.ini           | 27 +++++++++++++++++++--------
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/tests/conftest.py b/tests/conftest.py
index 68fdba7..a1ca97f 100755
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -51,6 +51,9 @@ def pytest_addoption(parser):
     parser.addoption('--remote-execution', action='store_true', default=False,
                      help='Run remote-execution tests only')
 
+    parser.addoption('--external-plugins', action='store_true', default=False,
+                     help="Run standardised tests for external plugins")
+
 
 def pytest_runtest_setup(item):
     # Without --integration: skip tests not marked with 'integration'
@@ -138,6 +141,10 @@ register_repo_kind('zip', Zip, None)
 def pytest_sessionstart(session):
     sourcetests_collection_hook(session)
 
+    if session.config.getvalue('external_plugins'):
+        import bst_plugins_experimental
+        bst_plugins_experimental.testutils.register_sources()
+
 
 #################################################
 #             Isolated environment              #
diff --git a/tox.ini b/tox.ini
index 309e0cc..ce36da9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,24 +15,32 @@ isolated_build = true
 usedevelop =
     # This is required by Cython in order to get coverage for cython files.
     py{35,36,37}-!nocover: True
+    plugins: True
 
 commands =
     # Running with coverage reporting enabled
-    py{35,36,37}-!external-!nocover: pytest --basetemp {envtmpdir} --cov=buildstream --cov-config .coveragerc {posargs}
+    py{35,36,37}-!nocover: pytest --basetemp {envtmpdir} --cov=buildstream --cov-config .coveragerc {posargs}
     py{35,36,37}-!nocover: mkdir -p .coverage-reports
-    external-!nocover: {envpython} {toxinidir}/tests/external_plugins.py {envtmpdir} --cov=buildstream --cov-append {posargs}
-    py{35,36,37}-!external-!nocover: mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}
-    py{35,36,37}-external-!nocover: - mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}
+    py{35,36,37}-!nocover: mv {envtmpdir}/.coverage {toxinidir}/.coverage-reports/.coverage.{env:COVERAGE_PREFIX:}{envname}
     # Running with coverage reporting disabled
-    py{35,36,37}-!external-nocover: pytest --basetemp {envtmpdir} {posargs}
-    external-nocover: {envpython} {toxinidir}/tests/external_plugins.py {envtmpdir} {posargs}
+    py{35,36,37}-nocover: pytest --basetemp {envtmpdir} {posargs}
+
+    plugins: pytest --basetemp {envtmpdir} --external-plugins {posargs}
+
+   
 deps =
     py{35,36,37}: -rrequirements/requirements.txt
     py{35,36,37}: -rrequirements/dev-requirements.txt
     py{35,36,37}: -rrequirements/plugin-requirements.txt
+    
+    plugins: -rrequirements/requirements.txt
+    plugins: -rrequirements/dev-requirements.txt
+    plugins: -rrequirements/plugin-requirements.txt
+    plugins: git+https://gitlab.com/buildstream/bst-plugins-experimental@coldtom/setup-py-improvements
+
 
     # Only require coverage and pytest-cov when using it
-    !nocover: -rrequirements/cov-requirements.txt
+    py{35,36,37}-!nocover: -rrequirements/cov-requirements.txt
 passenv =
     ARTIFACT_CACHE_SERVICE
     BST_FORCE_BACKEND
@@ -65,7 +73,10 @@ whitelist_externals =
     py{35,36,37}:
         mv
         mkdir
-
+    plugins:
+        rm
+        mv
+        git
 #
 # Coverage reporting
 #