Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/buildstream/_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions tests/frontend/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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

Expand All @@ -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("")
Expand Down