summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-02-23 17:35:58 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2019-02-24 18:48:00 +0900
commit18095c9befc53148e36740107b42dcb35d3a2fee (patch)
treeef20c7e36fe28e8209e73760d7a9a8c2f62a7689
parent2629bdd01197451cde59c94fa52f0d928b5401cf (diff)
downloadbuildstream-tristan/fix-workspace-build-all.tar.gz
tests/frontend/workspace.py: Test that all elements build with workspace in playtristan/fix-workspace-build-all
Tests that the target is still built even when a workspace is open on a runtime dependency of a build-only dependency. This adds the regression test provided by Matthew Yates for issue #919
-rw-r--r--tests/frontend/workspace.py42
-rw-r--r--tests/frontend/workspaced-build-dep/elements/elem1.bst5
-rw-r--r--tests/frontend/workspaced-build-dep/elements/elem2.bst5
-rw-r--r--tests/frontend/workspaced-build-dep/elements/elem3.bst9
-rw-r--r--tests/frontend/workspaced-build-dep/elements/stack.bst5
-rw-r--r--tests/frontend/workspaced-build-dep/files/file10
-rw-r--r--tests/frontend/workspaced-build-dep/files/file20
-rw-r--r--tests/frontend/workspaced-build-dep/files/file30
-rw-r--r--tests/frontend/workspaced-build-dep/project.conf8
9 files changed, 74 insertions, 0 deletions
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py
index 91004b9f4..a90ab97b2 100644
--- a/tests/frontend/workspace.py
+++ b/tests/frontend/workspace.py
@@ -1238,3 +1238,45 @@ def test_external_list(cli, datafiles, tmpdir_factory):
result = cli.run(project=project, args=['-C', workspace, 'workspace', 'list'])
result.assert_success()
+
+
+# This strange test tests against a regression raised in issue #919,
+# where opening a workspace on a runtime dependency of a build only
+# dependency causes `bst build` to not build the specified target
+# but just successfully builds the workspaced element and happily
+# exits without completing the build.
+#
+BUILD_ALL_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "workspaced-build-dep",
+)
+
+
+@pytest.mark.datafiles(BUILD_ALL_DIR)
+@pytest.mark.parametrize("strict", [("strict"), ("non-strict")])
+def test_build_all(cli, tmpdir, datafiles, strict):
+ project = str(datafiles)
+ workspace = os.path.join(str(tmpdir), 'workspace')
+
+ # Configure strict mode
+ strict_mode = True
+ if strict != 'strict':
+ strict_mode = False
+ cli.configure({
+ 'projects': {
+ 'test': {
+ 'strict': strict_mode
+ }
+ }
+ })
+
+ # First open the workspace
+ result = cli.run(project=project, args=['workspace', 'open', '--directory', workspace, 'elem1.bst'])
+ result.assert_success()
+
+ # Now build the target elem3.bst
+ result = cli.run(project=project, args=['build', 'elem3.bst'])
+ result.assert_success()
+
+ # Assert that the target is built
+ assert cli.get_element_state(project, 'elem3.bst') == 'cached'
diff --git a/tests/frontend/workspaced-build-dep/elements/elem1.bst b/tests/frontend/workspaced-build-dep/elements/elem1.bst
new file mode 100644
index 000000000..eed39a95a
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/elements/elem1.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: local
+ path: files/file1
diff --git a/tests/frontend/workspaced-build-dep/elements/elem2.bst b/tests/frontend/workspaced-build-dep/elements/elem2.bst
new file mode 100644
index 000000000..1233c0885
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/elements/elem2.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: local
+ path: files/file2
diff --git a/tests/frontend/workspaced-build-dep/elements/elem3.bst b/tests/frontend/workspaced-build-dep/elements/elem3.bst
new file mode 100644
index 000000000..4c9bf899c
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/elements/elem3.bst
@@ -0,0 +1,9 @@
+kind: import
+
+depends:
+- filename: stack.bst
+ type: build
+
+sources:
+- kind: local
+ path: files/file3
diff --git a/tests/frontend/workspaced-build-dep/elements/stack.bst b/tests/frontend/workspaced-build-dep/elements/stack.bst
new file mode 100644
index 000000000..6ba3614be
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/elements/stack.bst
@@ -0,0 +1,5 @@
+kind: stack
+
+depends:
+- elem1.bst
+- elem2.bst
diff --git a/tests/frontend/workspaced-build-dep/files/file1 b/tests/frontend/workspaced-build-dep/files/file1
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/files/file1
diff --git a/tests/frontend/workspaced-build-dep/files/file2 b/tests/frontend/workspaced-build-dep/files/file2
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/files/file2
diff --git a/tests/frontend/workspaced-build-dep/files/file3 b/tests/frontend/workspaced-build-dep/files/file3
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/files/file3
diff --git a/tests/frontend/workspaced-build-dep/project.conf b/tests/frontend/workspaced-build-dep/project.conf
new file mode 100644
index 000000000..e017957da
--- /dev/null
+++ b/tests/frontend/workspaced-build-dep/project.conf
@@ -0,0 +1,8 @@
+# Unique project name
+name: test
+
+# Required BuildStream format version
+format-version: 12
+
+# Subdirectory where elements are stored
+element-path: elements