summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2020-09-24 13:57:41 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2020-09-24 13:57:41 +0000
commitbb317336072f3bad2693718d03e8737113d863c5 (patch)
tree366d351331aca667c1ac6c4e50897f0dc68bacca
parent9fba7a1fb27da5fac968fc3eeedc2017b282f344 (diff)
parent4ec05a825881d3167caff4463725f8b4da594dbb (diff)
downloadbuildstream-bb317336072f3bad2693718d03e8737113d863c5.tar.gz
Merge branch 'juerg/filter-pass-integration' into 'master'
filter.py: Combine integration commands in assemble() See merge request BuildStream/buildstream!2073
-rw-r--r--src/buildstream/plugins/elements/filter.py23
-rw-r--r--tests/integration/filter.py32
2 files changed, 49 insertions, 6 deletions
diff --git a/src/buildstream/plugins/elements/filter.py b/src/buildstream/plugins/elements/filter.py
index 783079c06..5560f7b7a 100644
--- a/src/buildstream/plugins/elements/filter.py
+++ b/src/buildstream/plugins/elements/filter.py
@@ -249,6 +249,23 @@ class FilterElement(Element):
dep.stage_artifact(sandbox, include=self.include, exclude=self.exclude, orphans=self.include_orphans)
def assemble(self, sandbox):
+ if self.pass_integration:
+ build_deps = list(self.dependencies(recurse=False))
+ assert len(build_deps) == 1
+ dep = build_deps[0]
+
+ # Integration commands of the build dependency
+ pub_data = dep.get_public_data("bst")
+ integration_commands = pub_data.get_str_list("integration-commands", [])
+
+ # Integration commands of the filter element itself
+ filter_pub_data = self.get_public_data("bst")
+ filter_integration_commands = filter_pub_data.get_str_list("integration-commands", [])
+
+ # Concatenate the command lists
+ filter_pub_data["integration-commands"] = integration_commands + filter_integration_commands
+ self.set_public_data("bst", filter_pub_data)
+
return ""
def _get_source_element(self):
@@ -259,12 +276,6 @@ class FilterElement(Element):
output_elm = build_deps[0]._get_source_element()
return output_elm
- def integrate(self, sandbox):
- if self.pass_integration:
- for dep in self.dependencies(recurse=False):
- dep.integrate(sandbox)
- super().integrate(sandbox)
-
def setup():
return FilterElement
diff --git a/tests/integration/filter.py b/tests/integration/filter.py
index 12061fe7a..f8d2aff26 100644
--- a/tests/integration/filter.py
+++ b/tests/integration/filter.py
@@ -40,3 +40,35 @@ def test_filter_pass_integration(datafiles, cli):
# Check that the integration command was run
assert_contains(checkout_dir, ["/foo"])
shutil.rmtree(checkout_dir)
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR))
+@pytest.mark.skipif(not HAVE_SANDBOX, reason="Only available with a functioning sandbox")
+@pytest.mark.xfail(
+ HAVE_SANDBOX == "buildbox-run" and BUILDBOX_RUN == "buildbox-run-userchroot",
+ reason="Root directory not writable with userchroot",
+)
+def test_filter_pass_integration_uncached(datafiles, cli):
+ project = str(datafiles)
+
+ # Passing integration commands should build nicely
+ result = cli.run(project=project, args=["build", "filter/filter.bst"])
+ result.assert_success()
+
+ # Delete the build dependency of the filter element.
+ # The built filter element should be usable even if the build dependency
+ # is not available in the local cache.
+ result = cli.run(project=project, args=["artifact", "delete", "filter/parent.bst"])
+ result.assert_success()
+
+ # Checking out the element should work
+ checkout_dir = os.path.join(project, "filter")
+ result = cli.run(
+ project=project,
+ args=["artifact", "checkout", "--integrate", "--directory", checkout_dir, "filter/filter.bst"],
+ )
+ result.assert_success()
+
+ # Check that the integration command was run
+ assert_contains(checkout_dir, ["/foo"])
+ shutil.rmtree(checkout_dir)