summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Coldrick <thomas.coldrick@codethink.co.uk>2019-09-11 12:13:20 +0100
committerThomas Coldrick <othko97@gmail.com>2019-09-16 06:55:56 +0000
commite019f2fb2236ba30b002166dc836cdfe57a3e937 (patch)
tree38eaeb3d97e457f0844347085e055ed7a0589a3b
parent4e63710a5136c7ca8d87a5e86908e7de3de05f4a (diff)
downloadbuildstream-coldtom/filter-element-improvements.tar.gz
tests/integration: Add test for filter elementcoldtom/filter-element-improvements
Adds an integration test to check the `pass-integration` option for filter elements works.
-rw-r--r--tests/elements/filter.py5
-rw-r--r--tests/integration/filter.py36
-rw-r--r--tests/integration/project/elements/filter/filter.bst16
-rw-r--r--tests/integration/project/elements/filter/parent.bst20
4 files changed, 73 insertions, 4 deletions
diff --git a/tests/elements/filter.py b/tests/elements/filter.py
index fc64c0342..af3f348b2 100644
--- a/tests/elements/filter.py
+++ b/tests/elements/filter.py
@@ -523,10 +523,7 @@ def test_filter_fails_for_nonexisting_domain(datafiles, cli):
assert error in result.stderr
assert '- unknown_file' in result.stderr
-# TODO: Figure out how to check if the passed integration commands
-# are actually correct, this just makes sure things build and
-# some integration commands attempt to run
-#
+
@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
def test_filter_pass_integration(datafiles, cli):
project = str(datafiles)
diff --git a/tests/integration/filter.py b/tests/integration/filter.py
new file mode 100644
index 000000000..1d9c11b01
--- /dev/null
+++ b/tests/integration/filter.py
@@ -0,0 +1,36 @@
+# Pylint doesn't play well with fixtures and dependency injection from pytest
+# pylint: disable=redefined-outer-name
+
+import os
+import shutil
+import pytest
+
+from buildstream.testing import cli # pylint: disable=unused-import
+from buildstream.testing.integration import assert_contains
+from buildstream.testing._utils.site import HAVE_SANDBOX
+
+
+DATA_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ 'project'
+)
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR))
+@pytest.mark.skipif(not HAVE_SANDBOX, reason='Only available with a functioning sandbox')
+def test_filter_pass_integration(datafiles, cli):
+ project = str(datafiles)
+
+ # Passing integration commands should build nicely
+ result = cli.run(project=project, args=['build', 'filter/filter.bst'])
+ result.assert_success()
+
+ # Checking out the element should work
+ checkout_dir = os.path.join(project, 'filter')
+ result = cli.run(project=project, args=['artifact', 'checkout', '--integrate', '--hardlinks',
+ '--directory', checkout_dir, 'filter/filter.bst'])
+ result.assert_success()
+
+ # Check that the integration command was run
+ assert_contains(checkout_dir, ['/foo'])
+ shutil.rmtree(checkout_dir)
diff --git a/tests/integration/project/elements/filter/filter.bst b/tests/integration/project/elements/filter/filter.bst
new file mode 100644
index 000000000..78b5ff12d
--- /dev/null
+++ b/tests/integration/project/elements/filter/filter.bst
@@ -0,0 +1,16 @@
+kind: filter
+depends:
+- filename: filter/parent.bst
+ type: build
+config:
+ pass-integration: True
+
+ # `sh` is `/bin/sh`, and `/bin` is not covered by any split rule
+ # As a result, to include `sh` in the image, we need to include orphans
+ #
+ # However we can use this to minimise the size of the artifacts, which
+ # will hopefully reduce test time
+ #
+ include-orphans: True
+ exclude:
+ - runtime
diff --git a/tests/integration/project/elements/filter/parent.bst b/tests/integration/project/elements/filter/parent.bst
new file mode 100644
index 000000000..35ac74d35
--- /dev/null
+++ b/tests/integration/project/elements/filter/parent.bst
@@ -0,0 +1,20 @@
+kind: compose
+depends:
+- filename: base.bst
+ type: build
+public:
+ bst:
+ integration-commands:
+ - touch /foo
+config:
+ # `sh` is `/bin/sh`, and `/bin` is not covered by any split rule
+ # As a result, to include `sh` in the image, we need to include orphans
+ #
+ # However we can use this to minimise the size of the artifacts, which
+ # will hopefully reduce test time
+ #
+ include-orphans: True
+ include:
+ - runtime
+ exclude:
+ - runtime