summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <chandan@chandansingh.net>2019-07-18 22:27:53 +0100
committerChandan Singh <chandan@chandansingh.net>2019-07-18 22:31:26 +0100
commitb28993df94393a31f0e216c0a234d439b3d5f666 (patch)
tree22795b5152f0f3ef3c8830c71738b8d9e01ebeb1
parent34016e65fae9ce8e4ff883e1f5a48070ec43f7d3 (diff)
downloadbuildstream-chandan/workspace-force-no-checkout.tar.gz
tests: Add regression test for issue #1086chandan/workspace-force-no-checkout
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/workspace.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 6e23ec488..cc92abf47 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -355,6 +355,29 @@ 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)
+
+
@pytest.mark.datafiles(DATA_DIR)
def test_open_force_different_workspace(cli, tmpdir, datafiles):
_, project, workspace = open_workspace(cli, tmpdir, datafiles, 'git', False, "-alpha")