diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py index d326b9532..831ff1724 100644 --- a/src/buildstream/_stream.py +++ b/src/buildstream/_stream.py @@ -1174,6 +1174,9 @@ def workspace_reset(self, targets, *, soft): workspaces.save_config() self.workspace_open([element._get_full_name()], no_checkout=False, force=True, custom_dir=workspace_path) + if soft: + workspaces.save_config() + # workspace_exists # # Check if a workspace exists diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index e244c6005..14b8257f6 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -510,6 +510,7 @@ def test_reset(cli, tmpdir, datafiles): def test_reset_soft(cli, tmpdir, datafiles): # Open the workspace element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, "tar") + workspace_config_path = os.path.join(project, ".bst2", "workspaces.yml") assert cli.get_element_state(project, element_name) == "buildable" @@ -528,6 +529,10 @@ def test_reset_soft(cli, tmpdir, datafiles): key_2 = cli.get_element_key(project, element_name) assert key_2 != "{:?<64}".format("") + workspace_config = _yaml.load(workspace_config_path, shortname="workspaces.yml") + workspace_node = workspace_config.get_mapping("workspaces").get_mapping(element_name) + assert workspace_node.get_str("last_build", default=None) is not None + # workspace keys are not recalculated assert key_1 == key_2 @@ -550,6 +555,17 @@ def test_reset_soft(cli, tmpdir, datafiles): # and added this one assert os.path.exists(os.path.join(workspace, "etc", "pony.conf")) + workspace_config = _yaml.load(workspace_config_path, shortname="workspaces.yml") + workspace_node = workspace_config.get_mapping("workspaces").get_mapping(element_name) + assert workspace_node.get_str("last_build", default=None) is None + + # A new BuildStream invocation must keep the soft-reset state. + result = cli.run(project=project, args=["workspace", "list"]) + result.assert_success() + workspace_config = _yaml.load(workspace_config_path, shortname="workspaces.yml") + workspace_node = workspace_config.get_mapping("workspaces").get_mapping(element_name) + assert workspace_node.get_str("last_build", default=None) is None + assert cli.get_element_state(project, element_name) == "buildable" key_3 = cli.get_element_key(project, element_name) assert key_3 != "{:?<64}".format("")