diff options
author | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-06-29 18:27:36 +0100 |
---|---|---|
committer | Jonathan Maw <jonathan.maw@codethink.co.uk> | 2018-07-16 13:19:14 +0100 |
commit | ddeac63acc607706a5b8ebf1f1a57b38427aa301 (patch) | |
tree | 00112136f7dc1ec151d49c7376eb3bb2e8ce9517 | |
parent | bc5a40e3dccbe1cb8066171fc2c0a4a5abeaa31e (diff) | |
download | buildstream-ddeac63acc607706a5b8ebf1f1a57b38427aa301.tar.gz |
tests: Fix filter tests not checking whether files should be missing.
They weren't actually catching it if you checked-out the entire depended
element, instead of just the specified split domains
-rw-r--r-- | tests/plugins/filter.py | 15 | ||||
-rw-r--r-- | tests/plugins/filter/basic/element_plugins/dynamic.py | 35 | ||||
-rw-r--r-- | tests/plugins/filter/basic/elements/input-dynamic.bst | 10 | ||||
-rw-r--r-- | tests/plugins/filter/basic/elements/output-dynamic-include.bst | 7 | ||||
-rw-r--r-- | tests/plugins/filter/basic/project.conf | 5 |
5 files changed, 72 insertions, 0 deletions
diff --git a/tests/plugins/filter.py b/tests/plugins/filter.py index 45d679439..4a5ff3402 100644 --- a/tests/plugins/filter.py +++ b/tests/plugins/filter.py @@ -21,6 +21,20 @@ def test_filter_include(datafiles, cli, tmpdir): result = cli.run(project=project, args=['checkout', 'output-include.bst', checkout]) result.assert_success() assert os.path.exists(os.path.join(checkout, "foo")) + assert not os.path.exists(os.path.join(checkout, "bar")) + + +@pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) +def test_filter_include_dynamic(datafiles, cli, tmpdir): + project = os.path.join(datafiles.dirname, datafiles.basename) + result = cli.run(project=project, args=['build', 'output-dynamic-include.bst']) + result.assert_success() + + checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout') + result = cli.run(project=project, args=['checkout', 'output-dynamic-include.bst', checkout]) + result.assert_success() + assert os.path.exists(os.path.join(checkout, "foo")) + assert not os.path.exists(os.path.join(checkout, "bar")) @pytest.mark.datafiles(os.path.join(DATA_DIR, 'basic')) @@ -32,6 +46,7 @@ def test_filter_exclude(datafiles, cli, tmpdir): checkout = os.path.join(tmpdir.dirname, tmpdir.basename, 'checkout') result = cli.run(project=project, args=['checkout', 'output-exclude.bst', checkout]) result.assert_success() + assert not os.path.exists(os.path.join(checkout, "foo")) assert os.path.exists(os.path.join(checkout, "bar")) diff --git a/tests/plugins/filter/basic/element_plugins/dynamic.py b/tests/plugins/filter/basic/element_plugins/dynamic.py new file mode 100644 index 000000000..1208a4a4d --- /dev/null +++ b/tests/plugins/filter/basic/element_plugins/dynamic.py @@ -0,0 +1,35 @@ +from buildstream import Element, Scope + + +# Copies files from the dependent element but inserts split-rules using dynamic data +class DynamicElement(Element): + def configure(self, node): + self.node_validate(node, ['split-rules']) + self.split_rules = self.node_get_member(node, dict, 'split-rules') + + def preflight(self): + pass + + def get_unique_key(self): + return {'split-rules': self.split_rules} + + def configure_sandbox(self, sandbox): + pass + + def stage(self, sandbox): + pass + + def assemble(self, sandbox): + with self.timed_activity("Staging artifact", silent_nested=True): + for dep in self.dependencies(Scope.BUILD): + dep.stage_artifact(sandbox) + + bstdata = self.get_public_data("bst") + bstdata["split-rules"] = self.split_rules + self.set_public_data("bst", bstdata) + + return "" + + +def setup(): + return DynamicElement diff --git a/tests/plugins/filter/basic/elements/input-dynamic.bst b/tests/plugins/filter/basic/elements/input-dynamic.bst new file mode 100644 index 000000000..e39cefe74 --- /dev/null +++ b/tests/plugins/filter/basic/elements/input-dynamic.bst @@ -0,0 +1,10 @@ +kind: dynamic +depends: +- filename: input.bst + type: build +config: + split-rules: + foo: + - /foo + bar: + - /bar diff --git a/tests/plugins/filter/basic/elements/output-dynamic-include.bst b/tests/plugins/filter/basic/elements/output-dynamic-include.bst new file mode 100644 index 000000000..ea45c96ef --- /dev/null +++ b/tests/plugins/filter/basic/elements/output-dynamic-include.bst @@ -0,0 +1,7 @@ +kind: filter +depends: +- filename: input-dynamic.bst + type: build +config: + include: + - foo diff --git a/tests/plugins/filter/basic/project.conf b/tests/plugins/filter/basic/project.conf index 627522526..418ed02c6 100644 --- a/tests/plugins/filter/basic/project.conf +++ b/tests/plugins/filter/basic/project.conf @@ -1,2 +1,7 @@ name: test element-path: elements +plugins: +- origin: local + path: element_plugins + elements: + dynamic: 0 |