diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-02-23 17:35:58 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-03-24 21:24:24 +0900 |
commit | 16e37af1405bfeac61c616506f7c79a976ce37c8 (patch) | |
tree | 02812361cde8fd47077fd515331fcfcb98ff5e5a /tests/frontend | |
parent | 7270c6817d65e6dfc2a07ad0f688aae75c814fe5 (diff) | |
download | buildstream-16e37af1405bfeac61c616506f7c79a976ce37c8.tar.gz |
tests/frontend/workspace.py: Test that all elements build with workspace in playtristan/backport-update-state-changes-1.2
- Tests that the target is still built even when a workspace is open
on a runtime dependency of a build-only dependency.
- Tests that the target is still built even when a workspace is open
on a runtime dependency of a runtime dependency of a build-only
dependency
This adds the regression test provided by Matthew Yates for issue #919
This test differs from the one committed in master as:
- We have an orthogonal bug in 1.2.x where buildable elements show up
in a waiting state instead of a buildable state
- Some new APIs were used in the test case added in master, adjusted
to use only 1.2 APIs for the test case.
Diffstat (limited to 'tests/frontend')
23 files changed, 157 insertions, 0 deletions
diff --git a/tests/frontend/workspace.py b/tests/frontend/workspace.py index 8799362e8..1009ad3d8 100644 --- a/tests/frontend/workspace.py +++ b/tests/frontend/workspace.py @@ -782,3 +782,54 @@ def test_cache_key_workspace_in_dependencies(cli, tmpdir, datafiles, strict): # Check that the original /usr/bin/hello is not in the checkout assert not os.path.exists(os.path.join(checkout, 'usr', 'bin', 'hello')) + + +# 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. +# +TEST_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)) +) + + +@pytest.mark.datafiles(TEST_DIR) +@pytest.mark.parametrize( + ["case", "non_workspaced_elements_state"], + [ + ("workspaced-build-dep", ["waiting", "waiting", "waiting", "waiting", "waiting"]), + ("workspaced-runtime-dep", ["buildable", "buildable", "waiting", "waiting", "waiting"]) + ], +) +@pytest.mark.parametrize("strict", [("strict"), ("non-strict")]) +def test_build_all(cli, tmpdir, datafiles, case, strict, non_workspaced_elements_state): + project = os.path.join(str(datafiles), case) + workspace = os.path.join(str(tmpdir), 'workspace') + non_leaf_elements = ["elem2.bst", "elem3.bst", "stack.bst", "elem4.bst", "elem5.bst"] + all_elements = ["elem1.bst", *non_leaf_elements] + + # 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', 'elem1.bst', workspace]) + result.assert_success() + + # Now build the targets elem4.bst and elem5.bst + result = cli.run(project=project, args=['build', 'elem4.bst', 'elem5.bst']) + result.assert_success() + + # Assert that the target is built + for element in all_elements: + assert cli.get_element_state(project, element) == '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..52f03f8aa --- /dev/null +++ b/tests/frontend/workspaced-build-dep/elements/elem2.bst @@ -0,0 +1,9 @@ +kind: import + +depends: +- filename: elem1.bst + type: build + +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..a49b4bded --- /dev/null +++ b/tests/frontend/workspaced-build-dep/elements/elem3.bst @@ -0,0 +1,9 @@ +kind: import + +depends: +- filename: elem2.bst + type: build + +sources: +- kind: local + path: files/file3 diff --git a/tests/frontend/workspaced-build-dep/elements/elem4.bst b/tests/frontend/workspaced-build-dep/elements/elem4.bst new file mode 100644 index 000000000..9aa3432de --- /dev/null +++ b/tests/frontend/workspaced-build-dep/elements/elem4.bst @@ -0,0 +1,9 @@ +kind: import + +depends: +- filename: stack.bst + type: build + +sources: +- kind: local + path: files/file4 diff --git a/tests/frontend/workspaced-build-dep/elements/elem5.bst b/tests/frontend/workspaced-build-dep/elements/elem5.bst new file mode 100644 index 000000000..4fe2dcf58 --- /dev/null +++ b/tests/frontend/workspaced-build-dep/elements/elem5.bst @@ -0,0 +1,9 @@ +kind: import + +depends: +- filename: elem3.bst + type: build + +sources: +- kind: local + path: files/file4 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..b4c6002f0 --- /dev/null +++ b/tests/frontend/workspaced-build-dep/elements/stack.bst @@ -0,0 +1,4 @@ +kind: stack + +depends: +- elem3.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/files/file4 b/tests/frontend/workspaced-build-dep/files/file4 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/frontend/workspaced-build-dep/files/file4 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 diff --git a/tests/frontend/workspaced-runtime-dep/elements/elem1.bst b/tests/frontend/workspaced-runtime-dep/elements/elem1.bst new file mode 100644 index 000000000..eed39a95a --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/elements/elem1.bst @@ -0,0 +1,5 @@ +kind: import + +sources: +- kind: local + path: files/file1 diff --git a/tests/frontend/workspaced-runtime-dep/elements/elem2.bst b/tests/frontend/workspaced-runtime-dep/elements/elem2.bst new file mode 100644 index 000000000..5fb90dfc0 --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/elements/elem2.bst @@ -0,0 +1,9 @@ +kind: import + +depends: +- filename: elem1.bst + type: runtime + +sources: +- kind: local + path: files/file2 diff --git a/tests/frontend/workspaced-runtime-dep/elements/elem3.bst b/tests/frontend/workspaced-runtime-dep/elements/elem3.bst new file mode 100644 index 000000000..c429c329f --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/elements/elem3.bst @@ -0,0 +1,9 @@ +kind: import + +depends: +- filename: elem2.bst + type: runtime + +sources: +- kind: local + path: files/file3 diff --git a/tests/frontend/workspaced-runtime-dep/elements/elem4.bst b/tests/frontend/workspaced-runtime-dep/elements/elem4.bst new file mode 100644 index 000000000..9aa3432de --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/elements/elem4.bst @@ -0,0 +1,9 @@ +kind: import + +depends: +- filename: stack.bst + type: build + +sources: +- kind: local + path: files/file4 diff --git a/tests/frontend/workspaced-runtime-dep/elements/elem5.bst b/tests/frontend/workspaced-runtime-dep/elements/elem5.bst new file mode 100644 index 000000000..4fe2dcf58 --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/elements/elem5.bst @@ -0,0 +1,9 @@ +kind: import + +depends: +- filename: elem3.bst + type: build + +sources: +- kind: local + path: files/file4 diff --git a/tests/frontend/workspaced-runtime-dep/elements/stack.bst b/tests/frontend/workspaced-runtime-dep/elements/stack.bst new file mode 100644 index 000000000..b4c6002f0 --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/elements/stack.bst @@ -0,0 +1,4 @@ +kind: stack + +depends: +- elem3.bst diff --git a/tests/frontend/workspaced-runtime-dep/files/file1 b/tests/frontend/workspaced-runtime-dep/files/file1 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/files/file1 diff --git a/tests/frontend/workspaced-runtime-dep/files/file2 b/tests/frontend/workspaced-runtime-dep/files/file2 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/files/file2 diff --git a/tests/frontend/workspaced-runtime-dep/files/file3 b/tests/frontend/workspaced-runtime-dep/files/file3 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/files/file3 diff --git a/tests/frontend/workspaced-runtime-dep/files/file4 b/tests/frontend/workspaced-runtime-dep/files/file4 new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/frontend/workspaced-runtime-dep/files/file4 diff --git a/tests/frontend/workspaced-runtime-dep/project.conf b/tests/frontend/workspaced-runtime-dep/project.conf new file mode 100644 index 000000000..e017957da --- /dev/null +++ b/tests/frontend/workspaced-runtime-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 |