diff options
author | Qinusty <jrsmith9822@gmail.com> | 2018-08-01 16:14:50 +0000 |
---|---|---|
committer | Qinusty <jrsmith9822@gmail.com> | 2018-08-01 16:14:50 +0000 |
commit | 4a4fed7ae03f7e64929eaf6d12a8b538a4339c7e (patch) | |
tree | 260f045259f21bbf0656c5ca965008d3f33abb28 | |
parent | 62a250fefa33f9dcfdc54b09ab4ec4d276fa7891 (diff) | |
parent | 4c739e2af5af0debd8a3394f108fcb78a49a5d53 (diff) | |
download | buildstream-4a4fed7ae03f7e64929eaf6d12a8b538a4339c7e.tar.gz |
Merge branch 'mablanch/447-stack-trace-checkout' into 'master'
Handle checkout failure for unbuilt elements
See merge request BuildStream/buildstream!590
-rw-r--r-- | buildstream/_stream.py | 2 | ||||
-rw-r--r-- | buildstream/element.py | 6 | ||||
-rw-r--r-- | tests/frontend/buildcheckout.py | 10 |
3 files changed, 17 insertions, 1 deletions
diff --git a/buildstream/_stream.py b/buildstream/_stream.py index bd4b2ccf0..ad4e1066c 100644 --- a/buildstream/_stream.py +++ b/buildstream/_stream.py @@ -434,7 +434,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 2218ef94b..bec87815c 100644 --- a/buildstream/element.py +++ b/buildstream/element.py @@ -623,6 +623,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 1ec8f491f..f27005ada 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') |