Commit 3c692ee7 authored by Tristan Van Berkom's avatar Tristan Van Berkom

Merge branch 'valentindavid/447-stack-trace-checkout' into 'bst-1.2'

Handle checkout failure for unbuilt elements

See merge request !653
parents cbdeba7b 7a9cd5ff
Pipeline #27851406 passed with stages
in 66 minutes and 52 seconds
......@@ -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
#
......
......@@ -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 = []
......
......@@ -96,6 +96,16 @@ def test_build_checkout_deps(datafiles, cli, deps):
assert not os.path.exists(filename)
@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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment