From 35d7051a07451e0647f60963d0485908b1d0139a Mon Sep 17 00:00:00 2001 From: Tristan Maat Date: Mon, 23 Oct 2017 16:46:40 +0100 Subject: Issue #124: Add test for staging to element build directory --- tests/frontend/buildcheckout.py | 19 +++++++++++++++++++ tests/frontend/project/elements/install-to-build.bst | 4 ++++ .../frontend/project/elements/installed-to-build.bst | 11 +++++++++++ .../project/files/build-files/buildstream/build/test | 1 + 4 files changed, 35 insertions(+) create mode 100644 tests/frontend/project/elements/install-to-build.bst create mode 100644 tests/frontend/project/elements/installed-to-build.bst create mode 100644 tests/frontend/project/files/build-files/buildstream/build/test diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py index 197336d31..c57ccb02f 100644 --- a/tests/frontend/buildcheckout.py +++ b/tests/frontend/buildcheckout.py @@ -4,6 +4,7 @@ from tests.testutils import cli, create_repo, ALL_REPO_KINDS from tests.testutils.site import HAVE_OSTREE from buildstream import _yaml +from buildstream._pipeline import PipelineError # Project directory DATA_DIR = os.path.join( @@ -93,3 +94,21 @@ def test_fetch_build_checkout(cli, tmpdir, datafiles, strict, kind): # Check that the pony.h include from files/dev-files exists filename = os.path.join(checkout, 'usr', 'include', 'pony.h') assert os.path.exists(filename) + + +@pytest.mark.datafiles(DATA_DIR) +def test_install_to_build(cli, tmpdir, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + element = 'installed-to-build.bst' + + # Attempt building the element + # We expect this to throw an ElementError, since the element will + # attempt to stage into /buildstream/build, which is not allowed. + result = cli.run(project=project, args=strict_args(['build', element], True)) + assert result.exit_code != 0 + + # While the error thrown is an ElementError, the pipeline picks up + # the error and raises it as a PipelineError. Since we are testing + # through the cli runner, we can't be more specific. + assert result.exception + assert isinstance(result.exception, PipelineError) diff --git a/tests/frontend/project/elements/install-to-build.bst b/tests/frontend/project/elements/install-to-build.bst new file mode 100644 index 000000000..a892cc69c --- /dev/null +++ b/tests/frontend/project/elements/install-to-build.bst @@ -0,0 +1,4 @@ +kind: import +sources: +- kind: local + path: files/build-files diff --git a/tests/frontend/project/elements/installed-to-build.bst b/tests/frontend/project/elements/installed-to-build.bst new file mode 100644 index 000000000..2e963c977 --- /dev/null +++ b/tests/frontend/project/elements/installed-to-build.bst @@ -0,0 +1,11 @@ +kind: manual +sources: +- kind: local + path: files/build-files + +depends: +- filename: install-to-build.bst + type: build + +config: + strip-commands: [] diff --git a/tests/frontend/project/files/build-files/buildstream/build/test b/tests/frontend/project/files/build-files/buildstream/build/test new file mode 100644 index 000000000..9daeafb98 --- /dev/null +++ b/tests/frontend/project/files/build-files/buildstream/build/test @@ -0,0 +1 @@ +test -- cgit v1.2.1