diff options
-rw-r--r-- | src/buildstream/_frontend/cli.py | 2 | ||||
-rw-r--r-- | src/buildstream/_stream.py | 6 | ||||
-rw-r--r-- | tests/integration/shell.py | 2 | ||||
-rw-r--r-- | tests/integration/shellbuildtrees.py | 13 |
4 files changed, 11 insertions, 12 deletions
diff --git a/src/buildstream/_frontend/cli.py b/src/buildstream/_frontend/cli.py index 5e42bda68..ab06e8a8a 100644 --- a/src/buildstream/_frontend/cli.py +++ b/src/buildstream/_frontend/cli.py @@ -640,7 +640,7 @@ def shell(app, element, mount, isolate, build_, cli_buildtree, pull_, command): pull_=pull_, ) except BstError as e: - raise AppError("Error launching shell: {}".format(e), detail=e.detail) from e + raise AppError("Error launching shell: {}".format(e), detail=e.detail, reason=e.reason) from e # If there were no errors, we return the shell's exit code here. sys.exit(exitcode) diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index 0aff5fb94..e91ee882c 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -221,6 +221,7 @@ class Stream: raise StreamError( "Elements need to be built or downloaded before staging a shell environment", detail="\n".join(list(map(lambda x: x._get_full_name(), missing_deps))), + reason="shell-missing-deps", ) # Check if we require a pull queue attempt, with given artifact state and context @@ -229,11 +230,14 @@ class Stream: remotes_message = " or in available remotes" if pull_ else "" if not element._cached(): message = "Artifact not cached locally" + remotes_message + reason = "missing-buildtree-artifact-not-cached" elif element._buildtree_exists(): message = "Buildtree is not cached locally" + remotes_message + reason = "missing-buildtree-artifact-buildtree-not-cached" else: message = "Artifact was created without buildtree" - raise StreamError(message) + reason = "missing-buildtree-artifact-created-without-buildtree" + raise StreamError(message, reason=reason) # Raise warning if the element is cached in a failed state if element._cached_failure(): diff --git a/tests/integration/shell.py b/tests/integration/shell.py index 42e486bac..a022d86be 100644 --- a/tests/integration/shell.py +++ b/tests/integration/shell.py @@ -393,7 +393,7 @@ def test_integration_partial_artifact(cli, datafiles, tmpdir, integration_cache) # check shell doesn't work result = cli.run(project=project, args=["shell", element_name, "--", "hello"]) - result.assert_main_error(ErrorDomain.APP, None) + result.assert_main_error(ErrorDomain.APP, "shell-missing-deps") # check the artifact gets completed with '--pull' specified result = cli.run(project=project, args=["shell", "--pull", element_name, "--", "hello"]) diff --git a/tests/integration/shellbuildtrees.py b/tests/integration/shellbuildtrees.py index 5164c0209..65b2d9fae 100644 --- a/tests/integration/shellbuildtrees.py +++ b/tests/integration/shellbuildtrees.py @@ -69,8 +69,7 @@ def test_buildtree_staged_warn_empty_cached(cli_integration, tmpdir, datafiles): res = cli_integration.run( project=project, args=["shell", "--build", "--use-buildtree", element_name, "--", "cat", "test"] ) - res.assert_main_error(ErrorDomain.APP, None) - assert "Error launching shell: Artifact was created without buildtree" in res.stderr + res.assert_main_error(ErrorDomain.APP, "missing-buildtree-artifact-created-without-buildtree") @pytest.mark.datafiles(DATA_DIR) @@ -109,8 +108,7 @@ def test_buildtree_from_failure_option_never(cli_integration, tmpdir, datafiles) res = cli_integration.run( project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", "test"] ) - res.assert_main_error(ErrorDomain.APP, None) - assert "Error launching shell: Artifact was created without buildtree" in res.stderr + res.assert_main_error(ErrorDomain.APP, "missing-buildtree-artifact-created-without-buildtree") @pytest.mark.datafiles(DATA_DIR) @@ -229,9 +227,7 @@ def test_buildtree_options(cli, tmpdir, datafiles): result = cli.run(project=project, args=["artifact", "pull", "--deps", "all", element_name]) result.assert_success() res = cli.run(project=project, args=["shell", "--build", element_name, "--use-buildtree", "--", "cat", "test"]) - res.assert_main_error(ErrorDomain.APP, None) - assert "Buildtree is not cached locally" in res.stderr - assert "Hi" not in res.output + res.assert_main_error(ErrorDomain.APP, "missing-buildtree-artifact-buildtree-not-cached") # Check that when user context is set to pull buildtrees and a remote has the buildtree, # '--use-buildtree' will attempt and succeed at pulling the missing buildtree with --pull set. @@ -278,8 +274,7 @@ def test_pull_buildtree_pulled(cli, tmpdir, datafiles): project=project, args=["shell", "--build", element_name, "--pull", "--use-buildtree", "--", "cat", "test",], ) - res.assert_main_error(ErrorDomain.APP, None) - assert "Buildtree is not cached locally" in res.stderr + res.assert_main_error(ErrorDomain.APP, "missing-buildtree-artifact-buildtree-not-cached") # Check it's using the cached build tree, because --pull # and pull-buildtrees were both set |