From 95c3330af22b33c51157e7e02770d2cc58ab3e6a Mon Sep 17 00:00:00 2001 From: Tristan van Berkom Date: Wed, 9 Dec 2020 16:04:56 +0900 Subject: _stream.py: Added missing machine readable error codes In errors pertaining to failing to launch a shell with a buildtree. Other related updates: - _frontend/cli.py: Propagate machine readable error codes in `bst shell` This command prefixes a reported error, so it rewraps the error into an AppError, this needs to propagate the originating machine readable error. - tests/integration/shell.py, tests/integration/shellbuildtrees.py: Updated to use new machine readable errors --- tests/integration/shell.py | 2 +- tests/integration/shellbuildtrees.py | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'tests') 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 -- cgit v1.2.1