diff options
author | Thomas Coldrick <thomas.coldrick@codethink.co.uk> | 2019-09-12 15:40:48 +0100 |
---|---|---|
committer | Thomas Coldrick <othko97@gmail.com> | 2019-10-15 19:09:40 +0100 |
commit | dcb65313605dee2efe7e83a9dcb059c9a88a983b (patch) | |
tree | 3cda60550ecfe3526e4d3e397ff7ccfbbe31d980 | |
parent | 1aae25a9c15fed48bd12edc395b4cbf49f298860 (diff) | |
download | buildstream-dcb65313605dee2efe7e83a9dcb059c9a88a983b.tar.gz |
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.
-rw-r--r-- | setup.cfg | 8 | ||||
-rw-r--r-- | tests/format/variables.py | 2 | ||||
-rw-r--r-- | tests/format/variables/defaults/plugins/test.py | 18 | ||||
-rw-r--r-- | tests/format/variables/defaults/plugins/test.yaml | 28 | ||||
-rw-r--r-- | tests/format/variables/defaults/project.conf | 6 | ||||
-rw-r--r-- | tests/format/variables/defaults/test.bst | 2 | ||||
-rw-r--r-- | tests/format/variables/overrides/plugins/test.py | 18 | ||||
-rw-r--r-- | tests/format/variables/overrides/plugins/test.yaml | 28 | ||||
-rw-r--r-- | tests/format/variables/overrides/project.conf | 5 | ||||
-rw-r--r-- | tests/format/variables/overrides/test.bst | 4 |
10 files changed, 118 insertions, 1 deletions
@@ -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 5c4c94b3b..177e51827 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 000000000..0d793dd0e --- /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 000000000..432e23e09 --- /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 2027cc27a..4c1894de8 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 000000000..943eac362 --- /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 000000000..0d793dd0e --- /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 000000000..432e23e09 --- /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 2027cc27a..2fe3a8fb6 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 000000000..7094c6c54 --- /dev/null +++ b/tests/format/variables/overrides/test.bst @@ -0,0 +1,4 @@ +kind: test +description: Some kinda test element +variables: + configure: quuz |