From e019f2fb2236ba30b002166dc836cdfe57a3e937 Mon Sep 17 00:00:00 2001 From: Thomas Coldrick Date: Wed, 11 Sep 2019 12:13:20 +0100 Subject: tests/integration: Add test for filter element Adds an integration test to check the `pass-integration` option for filter elements works. --- tests/elements/filter.py | 5 +-- tests/integration/filter.py | 36 ++++++++++++++++++++++ .../integration/project/elements/filter/filter.bst | 16 ++++++++++ .../integration/project/elements/filter/parent.bst | 20 ++++++++++++ 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 tests/integration/filter.py create mode 100644 tests/integration/project/elements/filter/filter.bst create mode 100644 tests/integration/project/elements/filter/parent.bst 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 -- cgit v1.2.1