diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index a475bdb41..e6fe53d60 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -1152,8 +1152,9 @@ def workspace_reset(self, targets, *, soft): nonexisting = [] for element in elements: - if not self.workspace_exists(element.name): - nonexisting.append(element.name) + name = element._get_full_name() + if not self.workspace_exists(name): + nonexisting.append(name) if nonexisting: raise StreamError("Workspace does not exist", detail="\n".join(nonexisting)) diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index 8372a17cd..e243dec54 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -556,6 +556,32 @@ def test_reset_soft(cli, tmpdir, datafiles): assert key_1 != key_3 +@pytest.mark.datafiles(DATA_DIR) +def test_reset_junction_workspace(cli, tmpdir, datafiles): + project = str(datafiles) + workspace = os.path.join(str(tmpdir), "junction-workspace") + target = "nested.bst:import-etc.bst" + + _yaml.roundtrip_dump( + {"kind": "junction", "sources": [{"kind": "local", "path": "files/sub-project"}]}, + os.path.join(project, "elements", "nested.bst"), + ) + + result = cli.run(project=project, args=["workspace", "open", "--directory", workspace, target]) + result.assert_success() + + result = cli.run(project=project, args=["workspace", "reset", target]) + result.assert_success() + + result = cli.run(project=project, args=["workspace", "list"]) + result.assert_success() + loaded = _yaml.load_data(result.output) + workspaces = loaded.get_sequence("workspaces") + assert len(workspaces) == 1 + space = workspaces.mapping_at(0) + assert space.get_str("element") == target + + @pytest.mark.datafiles(DATA_DIR) def test_reset_multiple(cli, tmpdir, datafiles): # Open the workspaces