summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.com>2019-01-30 11:34:04 +0000
committerJames Ennis <james.ennis@codethink.com>2019-01-30 11:34:04 +0000
commit7256bb0c117c5bbb0bbe5b95350015a8612feb13 (patch)
treec3d518b68f1082340d3cc63e1dc7e4bc00ca8a59
parentaae35e13e8f5ed550d7ccdd6611482c225a4ff81 (diff)
parent03111d39e093b11ffc6589071f2f5040d5f61ab4 (diff)
downloadbuildstream-7256bb0c117c5bbb0bbe5b95350015a8612feb13.tar.gz
Merge branch 'doraskayo/filter-indirect-deps-fix' into 'master'
filter.py: don't recurse when staging dependencies Closes #883 See merge request BuildStream/buildstream!1110
-rw-r--r--buildstream/plugins/elements/filter.py4
-rw-r--r--tests/elements/filter.py20
-rw-r--r--tests/elements/filter/basic/elements/input-with-deps.bst14
-rw-r--r--tests/elements/filter/basic/elements/output-include-with-indirect-deps.bst5
4 files changed, 42 insertions, 1 deletions
diff --git a/buildstream/plugins/elements/filter.py b/buildstream/plugins/elements/filter.py
index 672325304..b2c292261 100644
--- a/buildstream/plugins/elements/filter.py
+++ b/buildstream/plugins/elements/filter.py
@@ -47,6 +47,8 @@ from buildstream import Element, ElementError, Scope
class FilterElement(Element):
# pylint: disable=attribute-defined-outside-init
+ BST_ARTIFACT_VERSION = 1
+
# The filter element's output is its dependencies, so
# we must rebuild if the dependencies change even when
# not in strict build plans.
@@ -102,7 +104,7 @@ class FilterElement(Element):
def assemble(self, sandbox):
with self.timed_activity("Staging artifact", silent_nested=True):
- for dep in self.dependencies(Scope.BUILD):
+ for dep in self.dependencies(Scope.BUILD, recurse=False):
dep.stage_artifact(sandbox, include=self.include,
exclude=self.exclude, orphans=self.include_orphans)
return ""
diff --git a/tests/elements/filter.py b/tests/elements/filter.py
index a63ef29e1..8ff642c64 100644
--- a/tests/elements/filter.py
+++ b/tests/elements/filter.py
@@ -464,3 +464,23 @@ def test_filter_track_multi_exclude(datafiles, cli, tmpdir):
assert "ref" not in new_input["sources"][0]
new_input2 = _yaml.load(input2_file)
assert new_input2["sources"][0]["ref"] == ref
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
+def test_filter_include_with_indirect_deps(datafiles, cli, tmpdir):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, args=[
+ 'build', 'output-include-with-indirect-deps.bst'])
+ result.assert_success()
+
+ checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout')
+ result = cli.run(project=project, args=[
+ 'artifact', 'checkout', 'output-include-with-indirect-deps.bst', '--directory', checkout])
+ result.assert_success()
+
+ # direct dependencies should be staged and filtered
+ assert os.path.exists(os.path.join(checkout, "baz"))
+
+ # indirect dependencies shouldn't be staged and filtered
+ assert not os.path.exists(os.path.join(checkout, "foo"))
+ assert not os.path.exists(os.path.join(checkout, "bar"))
diff --git a/tests/elements/filter/basic/elements/input-with-deps.bst b/tests/elements/filter/basic/elements/input-with-deps.bst
new file mode 100644
index 000000000..50aab573c
--- /dev/null
+++ b/tests/elements/filter/basic/elements/input-with-deps.bst
@@ -0,0 +1,14 @@
+kind: import
+
+depends:
+- filename: input.bst
+
+sources:
+- kind: local
+ path: files
+
+public:
+ bst:
+ split-rules:
+ baz:
+ - /baz
diff --git a/tests/elements/filter/basic/elements/output-include-with-indirect-deps.bst b/tests/elements/filter/basic/elements/output-include-with-indirect-deps.bst
new file mode 100644
index 000000000..8325853e2
--- /dev/null
+++ b/tests/elements/filter/basic/elements/output-include-with-indirect-deps.bst
@@ -0,0 +1,5 @@
+kind: filter
+
+depends:
+- filename: input-with-deps.bst
+ type: build