diff options
author | Tristan van Berkom <tristan@codethink.co.uk> | 2020-12-08 16:52:44 +0900 |
---|---|---|
committer | Tristan van Berkom <tristan@codethink.co.uk> | 2020-12-10 21:40:20 +0900 |
commit | 61cc93d57d7e2c4780cf23741e240cc56a2a5702 (patch) | |
tree | a52198f8414139157130d820fc864d412a584862 /tests | |
parent | fe6523ae7cda102a290eae670e62e317966234ac (diff) | |
download | buildstream-61cc93d57d7e2c4780cf23741e240cc56a2a5702.tar.gz |
plugins/elements/stack.py: Require all dependencies be build & run.
Stack elements cannot be build-only dependencies, as this would defeat
the purpose of using stack elements in order to directly build-depend on
them.
Stack element dependencies must all be built in order to build depend
on them, and as such we gain no build parallelism by allowing runtime-only
dependencies on stack elements. Declaring a runtime-only dependency on
a stack element as a whole might still be useful, but still requires the
entire stack to be built at the time we need that stack.
Instead, it is more useful to ensure that a stack element is a logical
group of all dependencies, including runtime dependencies, such that we
can guarantee cache key alignment with all stack dependencies.
This allows for stronger reliability in commands such as
`bst artifact checkout`, which can now reliably download and checkout
a fully built stack as a result, without any uncertainty about possible
runtime-only dependencies which might exist in the project where that
artifact was created.
This consequently closes #1075
This also fixes the following tests such that the no longer
require build-depends or runtime-depends to work in stack elements:
* tests/frontend/default_target.py: Was not necessary to check results of show,
these stacks were set to runtime-depends so that they would have the same
buildable state as their dependencies when shown.
* tests/format/dependencies.py: tests/frontend/pull.py, test/frontend/show.py,
tests/integration/compose.py:
These tests were using specific build/runtime dependencies in stacks, but
for no particular reason.
Diffstat (limited to 'tests')
9 files changed, 34 insertions, 30 deletions
diff --git a/tests/format/dependencies1/elements/builddep-list.bst b/tests/format/dependencies1/elements/builddep-list.bst index a0cbcaf23..eb216a127 100644 --- a/tests/format/dependencies1/elements/builddep-list.bst +++ b/tests/format/dependencies1/elements/builddep-list.bst @@ -1,4 +1,4 @@ -kind: stack +kind: manual description: This element has a build-only dependency specified via build-depends build-depends: - - firstdep.bst +- firstdep.bst diff --git a/tests/format/dependencies1/elements/list-combine.bst b/tests/format/dependencies1/elements/list-combine.bst index ed3452206..d39ddd38b 100644 --- a/tests/format/dependencies1/elements/list-combine.bst +++ b/tests/format/dependencies1/elements/list-combine.bst @@ -1,4 +1,4 @@ -kind: stack +kind: manual description: This element depends on three elements in different ways build-depends: - firstdep.bst diff --git a/tests/format/dependencies1/elements/runtimedep-list.bst b/tests/format/dependencies1/elements/runtimedep-list.bst index 1207a492d..eaa0cd2e0 100644 --- a/tests/format/dependencies1/elements/runtimedep-list.bst +++ b/tests/format/dependencies1/elements/runtimedep-list.bst @@ -1,4 +1,4 @@ -kind: stack +kind: manual description: This element has a runtime-only dependency runtime-depends: - - firstdep.bst +- firstdep.bst diff --git a/tests/frontend/default-target/elements/dummy_stack.bst b/tests/frontend/default-target/elements/dummy_stack.bst index 5f921667f..3ea51b00f 100644 --- a/tests/frontend/default-target/elements/dummy_stack.bst +++ b/tests/frontend/default-target/elements/dummy_stack.bst @@ -1,5 +1,5 @@ kind: stack -runtime-depends: +depends: - dummy_1.bst - dummy_2.bst diff --git a/tests/frontend/default_target.py b/tests/frontend/default_target.py index bb7a49592..60578bb8e 100644 --- a/tests/frontend/default_target.py +++ b/tests/frontend/default_target.py @@ -13,27 +13,27 @@ from tests.testutils import create_artifact_share DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "default-target",) -################################### -# build/show operations # -################################### - - +# +# When no target is default, then expect all targets to be built +# @pytest.mark.datafiles(DATA_DIR) -@pytest.mark.parametrize("operation,expected_state", [("show", "buildable"), ("build", "cached")]) -def test_no_default(cli, datafiles, operation, expected_state): +def test_no_default(cli, datafiles): project = str(datafiles) all_targets = ["dummy_1.bst", "dummy_2.bst", "dummy_3.bst", "dummy_stack.bst"] - result = cli.run(project=project, args=[operation]) + result = cli.run(project=project, args=["build"]) result.assert_success() states = cli.get_element_states(project, all_targets) - assert all(states[e] == expected_state for e in all_targets) + assert all(states[e] == "cached" for e in all_targets) +# +# When the stack is specified as the default target, then +# expect only it and it's dependencies to be built +# @pytest.mark.datafiles(DATA_DIR) -@pytest.mark.parametrize("operation,expected_state", [("show", "buildable"), ("build", "cached")]) -def test_default_target(cli, datafiles, operation, expected_state): +def test_default_target(cli, datafiles): project = str(datafiles) project_path = os.path.join(project, "project.conf") @@ -49,19 +49,23 @@ def test_default_target(cli, datafiles, operation, expected_state): # dummy_stack only depends on dummy_1 and dummy_2, but not dummy_3 all_targets = ["dummy_1.bst", "dummy_2.bst", "dummy_stack.bst"] - result = cli.run(project=project, args=[operation]) + result = cli.run(project=project, args=["build"]) result.assert_success() states = cli.get_element_states(project, all_targets) - assert all(states[e] == expected_state for e in all_targets) + assert all(states[e] == "cached" for e in all_targets) # assert that dummy_3 isn't included in the output assert "dummy_3.bst" not in states +# +# Even when there is a junction, expect that the elements in the +# subproject referred to by the toplevel project are built when +# calling `bst build` and no default is specified. +# @pytest.mark.datafiles(DATA_DIR) -@pytest.mark.parametrize("operation,expected_state", [("show", "buildable"), ("build", "cached")]) -def test_no_default_with_junction(cli, datafiles, operation, expected_state): +def test_no_default_with_junction(cli, datafiles): project = str(datafiles) junction_path = os.path.join(project, "elements", "junction.bst") target_path = os.path.join(project, "elements", "junction-target.bst") @@ -71,16 +75,16 @@ def test_no_default_with_junction(cli, datafiles, operation, expected_state): _yaml.roundtrip_dump(junction_config, junction_path) # Then, create a stack element with dependency on cross junction element - target_config = {"kind": "stack", "runtime-depends": ["junction.bst:dummy_subproject.bst"]} + target_config = {"kind": "stack", "depends": ["junction.bst:dummy_subproject.bst"]} _yaml.roundtrip_dump(target_config, target_path) - # Now try to perform the specified operation. + # Now try to perform a build # This should automatically fetch the junction at load time. - result = cli.run(project=project, args=[operation]) + result = cli.run(project=project, args=["build"]) result.assert_success() - assert cli.get_element_state(project, "junction.bst:dummy_subproject.bst") == expected_state - assert cli.get_element_state(project, "junction-target.bst") == expected_state + assert cli.get_element_state(project, "junction.bst:dummy_subproject.bst") == "cached" + assert cli.get_element_state(project, "junction-target.bst") == "cached" ################################### diff --git a/tests/frontend/pull.py b/tests/frontend/pull.py index c1fa76ab0..f873ad96e 100644 --- a/tests/frontend/pull.py +++ b/tests/frontend/pull.py @@ -338,7 +338,7 @@ def test_pull_missing_local_blob(cli, tmpdir, datafiles): _yaml.roundtrip_dump(input_config, input_file) depends_name = "depends.bst" - depends_config = {"kind": "stack", "depends": [{"filename": input_name, "type": "build"}]} + depends_config = {"kind": "stack", "depends": [input_name]} depends_file = os.path.join(element_dir, depends_name) _yaml.roundtrip_dump(depends_config, depends_file) diff --git a/tests/frontend/strict-depends/elements/non-strict-depends.bst b/tests/frontend/strict-depends/elements/non-strict-depends.bst index 9ab119bde..e0ed21ed6 100644 --- a/tests/frontend/strict-depends/elements/non-strict-depends.bst +++ b/tests/frontend/strict-depends/elements/non-strict-depends.bst @@ -1,4 +1,4 @@ kind: stack -build-depends: +depends: - base.bst diff --git a/tests/frontend/strict-depends/elements/strict-depends.bst b/tests/frontend/strict-depends/elements/strict-depends.bst index 1e4e29414..10f3b9418 100644 --- a/tests/frontend/strict-depends/elements/strict-depends.bst +++ b/tests/frontend/strict-depends/elements/strict-depends.bst @@ -1,5 +1,5 @@ kind: stack -build-depends: +depends: - filename: base.bst strict: true diff --git a/tests/integration/project/elements/compose/test-integration.bst b/tests/integration/project/elements/compose/test-integration.bst index 2f9faf170..ef47b3b58 100644 --- a/tests/integration/project/elements/compose/test-integration.bst +++ b/tests/integration/project/elements/compose/test-integration.bst @@ -1,6 +1,6 @@ kind: stack -runtime-depends: +depends: - base.bst public: |