From 2a33f557b6c3c940bdef3b539d7117c439ecc1ac Mon Sep 17 00:00:00 2001 From: Valentin David Date: Wed, 22 Aug 2018 20:31:43 +0200 Subject: Improve error message for deleted open workspaces Fixes #576. --- buildstream/_pipeline.py | 13 ++++++++++++- tests/frontend/workspace.py | 13 +++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/buildstream/_pipeline.py b/buildstream/_pipeline.py index 3b9fb0de9..17264ae23 100644 --- a/buildstream/_pipeline.py +++ b/buildstream/_pipeline.py @@ -355,10 +355,14 @@ class Pipeline(): # def assert_consistent(self, elements): inconsistent = [] + inconsistent_workspaced = [] with self._context.timed_activity("Checking sources"): for element in elements: if element._get_consistency() == Consistency.INCONSISTENT: - inconsistent.append(element) + if element._get_workspace(): + inconsistent_workspaced.append(element) + else: + inconsistent.append(element) if inconsistent: detail = "Exact versions are missing for the following elements:\n\n" @@ -372,6 +376,13 @@ class Pipeline(): raise PipelineError("Inconsistent pipeline", detail=detail, reason="inconsistent-pipeline") + if inconsistent_workspaced: + detail = "Some workspaces do not exist but are not closed\n" + \ + "Try closing them with `bst workspace close`\n\n" + for element in inconsistent_workspaced: + detail += " " + element._get_full_name() + "\n" + raise PipelineError("Inconsistent pipeline", detail=detail, reason="inconsistent-pipeline-workspaced") + ############################################################# # Private Methods # ############################################################# diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index 566fbb1cd..97fcd93d4 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -699,3 +699,16 @@ def test_list_supported_workspace(cli, tmpdir, datafiles, workspace_cfg, expecte # Check that workspace config is converted correctly if necessary loaded_config = _yaml.node_sanitize(_yaml.load(workspace_config_path)) assert loaded_config == parse_dict_as_yaml(expected) + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("kind", repo_kinds) +def test_inconsitent_pipeline_message(cli, tmpdir, datafiles, kind): + element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, kind, False) + + shutil.rmtree(workspace) + + result = cli.run(project=project, args=[ + 'build', element_name + ]) + result.assert_main_error(ErrorDomain.PIPELINE, "inconsistent-pipeline-workspaced") -- cgit v1.2.1