summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-07-19 18:29:08 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-19 18:29:08 +0000
commitff39b3524f3c544b1a08cb8e26da160e143e5266 (patch)
tree0cfa2421c8543255f5adb2b2316e0b6efda9b88b
parent4de721d62bec7ab07f55e425c2d2388e0923cd56 (diff)
parent4db64fcdd73c4bc09be2d68132858989280c69d3 (diff)
downloadbuildstream-traveltissues/benchmark-1088.tar.gz
Merge branch 'chandan/workspace-force-no-checkout' into 'master'traveltissues/benchmark-1088
Don't remove workspace directory when `--no-checkout` option is given Closes #1086 See merge request BuildStream/buildstream!1490
-rw-r--r--src/buildstream/_stream.py4
-rw-r--r--tests/frontend/project/elements/test.bst0
-rw-r--r--tests/frontend/workspace.py25
3 files changed, 27 insertions, 2 deletions
diff --git a/src/buildstream/_stream.py b/src/buildstream/_stream.py
index 11ac53f3f..d791449cc 100644
--- a/src/buildstream/_stream.py
+++ b/src/buildstream/_stream.py
@@ -771,14 +771,14 @@ class Stream():
.format(target.name, directory), reason='bad-directory')
# So far this function has tried to catch as many issues as possible with out making any changes
- # Now it dose the bits that can not be made atomic.
+ # Now it does the bits that can not be made atomic.
targetGenerator = zip(elements, expanded_directories)
for target, directory in targetGenerator:
self._message(MessageType.INFO, "Creating workspace for element {}"
.format(target.name))
workspace = workspaces.get_workspace(target._get_full_name())
- if workspace:
+ if workspace and not no_checkout:
workspaces.delete_workspace(target._get_full_name())
workspaces.save_config()
shutil.rmtree(directory)
diff --git a/tests/frontend/project/elements/test.bst b/tests/frontend/project/elements/test.bst
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/frontend/project/elements/test.bst
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 6e23ec488..ad0fc7371 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -355,6 +355,31 @@ def test_open_force_open(cli, tmpdir, datafiles):
result.assert_success()
+# Regression test for #1086.
+@pytest.mark.datafiles(DATA_DIR)
+def test_open_force_open_no_checkout(cli, tmpdir, datafiles):
+ element_name, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False)
+ hello_path = os.path.join(workspace, 'hello.txt')
+
+ # Assert the workspace dir exists
+ assert os.path.exists(workspace)
+
+ # Create a new file in the workspace
+ with open(hello_path, 'w') as f:
+ f.write('hello')
+
+ # Now open the workspace again with --force and --no-checkout
+ result = cli.run(project=project, args=[
+ 'workspace', 'open', '--force', '--no-checkout', '--directory', workspace, element_name
+ ])
+ result.assert_success()
+
+ # Ensure that our files were not overwritten
+ assert os.path.exists(hello_path)
+ with open(hello_path) as f:
+ assert f.read() == 'hello'
+
+
@pytest.mark.datafiles(DATA_DIR)
def test_open_force_different_workspace(cli, tmpdir, datafiles):
_, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False, "-alpha")