summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2018-08-14 08:17:23 +0000
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-08-14 08:17:23 +0000
commit3c692ee7c10d2186804fad040806cbe54d02c9fc (patch)
tree37c12244ba066e847dce31c02237da21cc09643d
parentcbdeba7b8052cbfce68f53a1a7eb231ce854945f (diff)
parent7a9cd5ffbaf24ca96677940ca5b3ef28fcacc847 (diff)
downloadbuildstream-3c692ee7c10d2186804fad040806cbe54d02c9fc.tar.gz
Merge branch 'valentindavid/447-stack-trace-checkout' into 'bst-1.2'
Handle checkout failure for unbuilt elements See merge request BuildStream/buildstream!653
-rw-r--r--buildstream/_stream.py2
-rw-r--r--buildstream/element.py6
-rw-r--r--tests/frontend/buildcheckout.py10
3 files changed, 17 insertions, 1 deletions
diff --git a/buildstream/_stream.py b/buildstream/_stream.py
index 798ab9a33..252bed26e 100644
--- a/buildstream/_stream.py
+++ b/buildstream/_stream.py
@@ -437,7 +437,7 @@ class Stream():
except BstError as e:
raise StreamError("Error while staging dependencies into a sandbox"
- ": '{}'".format(e), reason=e.reason) from e
+ ": '{}'".format(e), detail=e.detail, reason=e.reason) from e
# workspace_open
#
diff --git a/buildstream/element.py b/buildstream/element.py
index ffdead527..c181f760b 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -613,6 +613,12 @@ class Element(Plugin):
dep.stage_artifact(sandbox)
"""
+ if not self._cached():
+ detail = "No artifacts have been cached yet for that element\n" + \
+ "Try building the element first with `bst build`\n"
+ raise ElementError("No artifacts to stage",
+ detail=detail, reason="uncached-checkout-attempt")
+
if update_mtimes is None:
update_mtimes = []
diff --git a/tests/frontend/buildcheckout.py b/tests/frontend/buildcheckout.py
index b9d833f24..d0f52d6a7 100644
--- a/tests/frontend/buildcheckout.py
+++ b/tests/frontend/buildcheckout.py
@@ -97,6 +97,16 @@ def test_build_checkout_deps(datafiles, cli, deps):
@pytest.mark.datafiles(DATA_DIR)
+def test_build_checkout_unbuilt(datafiles, cli):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ checkout = os.path.join(cli.directory, 'checkout')
+
+ # Check that checking out an unbuilt element fails nicely
+ result = cli.run(project=project, args=['checkout', 'target.bst', checkout])
+ result.assert_main_error(ErrorDomain.STREAM, "uncached-checkout-attempt")
+
+
+@pytest.mark.datafiles(DATA_DIR)
def test_build_checkout_tarball(datafiles, cli):
project = os.path.join(datafiles.dirname, datafiles.basename)
checkout = os.path.join(cli.directory, 'checkout.tar')