summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2017-10-23 16:46:40 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2017-10-23 17:11:45 +0100
commit35d7051a07451e0647f60963d0485908b1d0139a (patch)
tree8eb461573f14363a45056702d282be5736a40f08
parent32667b24b801f9b51da026b08e89f7fc55d8ac65 (diff)
downloadbuildstream-124-test-that-an-error-is-raised-when-staging-to-the-elements-build-directory.tar.gz
Issue #124: Add test for staging to element build directory124-test-that-an-error-is-raised-when-staging-to-the-elements-build-directory
-rw-r--r--tests/frontend/buildcheckout.py19
-rw-r--r--tests/frontend/project/elements/install-to-build.bst4
-rw-r--r--tests/frontend/project/elements/installed-to-build.bst11
-rw-r--r--tests/frontend/project/files/build-files/buildstream/build/test1
4 files changed, 35 insertions, 0 deletions
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