summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <chandan@chandansingh.net>2019-07-18 22:27:53 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-19 17:53:16 +0000
commit4db64fcdd73c4bc09be2d68132858989280c69d3 (patch)
tree0cfa2421c8543255f5adb2b2316e0b6efda9b88b
parent87ed33882397782511fce4529e3ca661e939f164 (diff)
downloadbuildstream-4db64fcdd73c4bc09be2d68132858989280c69d3.tar.gz
tests: Add regression test for issue #1086
Ensure that any changes made by user in an open workspace are not overridden when calling `bst workspace open` again with `--force` and `--no-checkout` options.
-rw-r--r--tests/frontend/project/elements/test.bst0
-rw-r--r--tests/frontend/workspace.py25
2 files changed, 25 insertions, 0 deletions
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")