Dor Askayo pushed to branch doraskayo/filter-indirect-deps-fix at BuildStream / buildstream
Commits:
-
9b4242d7
by Dor Askayo at 2019-01-28T21:43:53Z
4 changed files:
- buildstream/plugins/elements/filter.py
- tests/elements/filter.py
- + tests/elements/filter/basic/elements/input-with-deps.bst
- + tests/elements/filter/basic/elements/output-include-with-indirect-deps.bst
Changes:
... | ... | @@ -47,6 +47,8 @@ from buildstream import Element, ElementError, Scope |
47 | 47 |
class FilterElement(Element):
|
48 | 48 |
# pylint: disable=attribute-defined-outside-init
|
49 | 49 |
|
50 |
+ BST_ARTIFACT_VERSION = 1
|
|
51 |
+ |
|
50 | 52 |
# The filter element's output is its dependencies, so
|
51 | 53 |
# we must rebuild if the dependencies change even when
|
52 | 54 |
# not in strict build plans.
|
... | ... | @@ -102,7 +104,7 @@ class FilterElement(Element): |
102 | 104 |
|
103 | 105 |
def assemble(self, sandbox):
|
104 | 106 |
with self.timed_activity("Staging artifact", silent_nested=True):
|
105 |
- for dep in self.dependencies(Scope.BUILD):
|
|
107 |
+ for dep in self.dependencies(Scope.BUILD, recurse=False):
|
|
106 | 108 |
dep.stage_artifact(sandbox, include=self.include,
|
107 | 109 |
exclude=self.exclude, orphans=self.include_orphans)
|
108 | 110 |
return ""
|
... | ... | @@ -464,3 +464,19 @@ def test_filter_track_multi_exclude(datafiles, cli, tmpdir): |
464 | 464 |
assert "ref" not in new_input["sources"][0]
|
465 | 465 |
new_input2 = _yaml.load(input2_file)
|
466 | 466 |
assert new_input2["sources"][0]["ref"] == ref
|
467 |
+ |
|
468 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic'))
|
|
469 |
+def test_filter_include_with_indirect_deps(datafiles, cli, tmpdir):
|
|
470 |
+ project = os.path.join(datafiles.dirname, datafiles.basename)
|
|
471 |
+ result = cli.run(project=project, args=['build', 'output-include-with-indirect-deps.bst'])
|
|
472 |
+ result.assert_success()
|
|
473 |
+ |
|
474 |
+ checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout')
|
|
475 |
+ result = cli.run(project=project, args=['artifact', 'checkout', 'output-include-with-indirect-deps.bst', '--directory', checkout])
|
|
476 |
+ result.assert_success()
|
|
477 |
+ |
|
478 |
+ # direct dependencies should be staged and filtered
|
|
479 |
+ assert os.path.exists(os.path.join(checkout, "baz"))
|
|
480 |
+ |
|
481 |
+ # indirect dependencies shouldn't be staged and filtered
|
|
482 |
+ assert not os.path.exists(os.path.join(checkout, "foo"))
|
1 |
+kind: import
|
|
2 |
+ |
|
3 |
+depends:
|
|
4 |
+- filename: input.bst
|
|
5 |
+ |
|
6 |
+sources:
|
|
7 |
+- kind: local
|
|
8 |
+ path: files
|
|
9 |
+ |
|
10 |
+public:
|
|
11 |
+ bst:
|
|
12 |
+ split-rules:
|
|
13 |
+ baz:
|
|
14 |
+ - /baz
|
1 |
+kind: filter
|
|
2 |
+ |
|
3 |
+depends:
|
|
4 |
+- filename: input-with-deps.bst
|
|
5 |
+ type: build
|
|
6 |
+ |
|
7 |
+config:
|
|
8 |
+ include:
|
|
9 |
+ - foo
|
|
10 |
+ - baz
|