diff options
author | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-07-25 13:18:59 +0900 |
---|---|---|
committer | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-07-25 19:06:25 +0900 |
commit | 84c67ce7952e32d6885908d494b5df04712077de (patch) | |
tree | 0b822739d9ee3e5e7002beefcec704841c4028bf | |
parent | 6165611ba47bd6c5139617e6e23d3068231c3844 (diff) | |
download | buildstream-84c67ce7952e32d6885908d494b5df04712077de.tar.gz |
tests/plugins/search.py: Adding test to thoroughly exercise Element.search()tristan/relative-search-paths
37 files changed, 282 insertions, 0 deletions
diff --git a/tests/plugins/search.py b/tests/plugins/search.py new file mode 100644 index 000000000..d10886c90 --- /dev/null +++ b/tests/plugins/search.py @@ -0,0 +1,79 @@ +# Pylint doesn't play well with fixtures and dependency injection from pytest +# pylint: disable=redefined-outer-name + +import os +import pytest + +from buildstream.testing import cli # pylint: disable=unused-import + +DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "search") + + +#################################################### +# Tests # +#################################################### +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize( + "target", + [ + # Search for an element in the same project which the element also depends on directly + # + "search-manual.bst", + # + # Search using a link to the manual element, where the manual element + # is listed as a dependency (ensures that link resolution works with + # Element.search()) + # + "search-link.bst", + # + # Search for an element in a subproject which is also directly depended on + # + "search-subproject.bst", + # + # Search for a local link which links to a subproject element + # + "search-link-to-subproject.bst", + # + # Search for a link to a subproject element within that same subproject + # + "search-link-in-subproject.bst", + # + # Search for an element where the search element is in a subproject + # + "subproject.bst:search-target.bst", + # + # Search for an element via a link where the search element is in a subproject + # + "subproject.bst:search-link.bst", + # + # Search for an element in a subsubproject, where the search element is in a subproject + # + "subproject.bst:search-subsubproject.bst", + # + # Search for a link which links to a subsubproject element, within a subproject + # + "subproject.bst:search-link-to-subsubproject.bst", + # + # Search for a link to a subsubproject element within that same subsubproject, all + # within a subproject. + # + "subproject.bst:search-link-in-subsubproject.bst", + # + # Search for an element in an overridden subproject + # + "subproject.bst:search-overridden-subsubproject.bst", + # + # Search for a link which links to an overridden subsubproject element + # + "subproject.bst:search-link-to-overridden-subsubproject.bst", + # + # Search for a link to a subsubproject element within an overridden subsubproject. + # + "subproject.bst:search-link-in-overridden-subsubproject.bst", + ], +) +def test_search(cli, datafiles, target): + project = str(datafiles) + + result = cli.run(project=project, args=["show", target]) + result.assert_success() diff --git a/tests/plugins/search/manual-link.bst b/tests/plugins/search/manual-link.bst new file mode 100644 index 000000000..b30960271 --- /dev/null +++ b/tests/plugins/search/manual-link.bst @@ -0,0 +1,4 @@ +kind: link + +config: + target: manual.bst diff --git a/tests/plugins/search/manual.bst b/tests/plugins/search/manual.bst new file mode 100644 index 000000000..4d7f70266 --- /dev/null +++ b/tests/plugins/search/manual.bst @@ -0,0 +1 @@ +kind: manual diff --git a/tests/plugins/search/project.conf b/tests/plugins/search/project.conf new file mode 100644 index 000000000..5d52d24d1 --- /dev/null +++ b/tests/plugins/search/project.conf @@ -0,0 +1,12 @@ +# This project.conf gets rewritten for each plugin loading test +name: test + +# Required BuildStream version +min-version: 2.0 + +# Configure the search element plugin +plugins: +- origin: junction + junction: subproject.bst + elements: + - search diff --git a/tests/plugins/search/search-link-in-subproject.bst b/tests/plugins/search/search-link-in-subproject.bst new file mode 100644 index 000000000..d7cbeb677 --- /dev/null +++ b/tests/plugins/search/search-link-in-subproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subproject.bst:target.bst + +config: + search: subproject.bst:target-link.bst diff --git a/tests/plugins/search/search-link-to-subproject.bst b/tests/plugins/search/search-link-to-subproject.bst new file mode 100644 index 000000000..e104da5c5 --- /dev/null +++ b/tests/plugins/search/search-link-to-subproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subproject.bst:target.bst + +config: + search: subproject-target-link.bst diff --git a/tests/plugins/search/search-link.bst b/tests/plugins/search/search-link.bst new file mode 100644 index 000000000..281292e8d --- /dev/null +++ b/tests/plugins/search/search-link.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- manual.bst + +config: + search: manual-link.bst diff --git a/tests/plugins/search/search-manual.bst b/tests/plugins/search/search-manual.bst new file mode 100644 index 000000000..9254cda2f --- /dev/null +++ b/tests/plugins/search/search-manual.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- manual.bst + +config: + search: manual.bst diff --git a/tests/plugins/search/search-subproject.bst b/tests/plugins/search/search-subproject.bst new file mode 100644 index 000000000..a2faf4b9e --- /dev/null +++ b/tests/plugins/search/search-subproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subproject.bst:target.bst + +config: + search: subproject.bst:target.bst diff --git a/tests/plugins/search/subproject-target-link.bst b/tests/plugins/search/subproject-target-link.bst new file mode 100644 index 000000000..3da195d89 --- /dev/null +++ b/tests/plugins/search/subproject-target-link.bst @@ -0,0 +1,4 @@ +kind: link + +config: + target: subproject.bst:target.bst diff --git a/tests/plugins/search/subproject.bst b/tests/plugins/search/subproject.bst new file mode 100644 index 000000000..edb1e3e33 --- /dev/null +++ b/tests/plugins/search/subproject.bst @@ -0,0 +1,8 @@ +kind: junction +sources: +- kind: local + path: subproject + +config: + overrides: + subsubproject2.bst: subsubproject2.bst diff --git a/tests/plugins/search/subproject/plugins/search.py b/tests/plugins/search/subproject/plugins/search.py new file mode 100644 index 000000000..2f93163fb --- /dev/null +++ b/tests/plugins/search/subproject/plugins/search.py @@ -0,0 +1,23 @@ +from buildstream import Element, Scope + + +class Search(Element): + BST_MIN_VERSION = "2.0" + + def configure(self, node): + self.search_element_path = node.get_str("search") + self.search_element = None + + def preflight(self): + self.search_element = self.search(Scope.ALL, self.search_element_path) + + assert self.search_element is not None + assert isinstance(self.search_element, Element) + + def get_unique_key(self): + return {} + + +# Plugin entry point +def setup(): + return Search diff --git a/tests/plugins/search/subproject/project.conf b/tests/plugins/search/subproject/project.conf new file mode 100644 index 000000000..8822950ea --- /dev/null +++ b/tests/plugins/search/subproject/project.conf @@ -0,0 +1,9 @@ +name: subtest +min-version: 2.0 + +# Configure the search element plugin +plugins: +- origin: local + path: plugins + elements: + - search diff --git a/tests/plugins/search/subproject/search-link-in-overridden-subsubproject.bst b/tests/plugins/search/subproject/search-link-in-overridden-subsubproject.bst new file mode 100644 index 000000000..46f3e8dc5 --- /dev/null +++ b/tests/plugins/search/subproject/search-link-in-overridden-subsubproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subsubproject2.bst:target.bst + +config: + search: subsubproject2.bst:target-link.bst diff --git a/tests/plugins/search/subproject/search-link-in-subsubproject.bst b/tests/plugins/search/subproject/search-link-in-subsubproject.bst new file mode 100644 index 000000000..063e69c50 --- /dev/null +++ b/tests/plugins/search/subproject/search-link-in-subsubproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subsubproject.bst:target.bst + +config: + search: subsubproject.bst:target-link.bst diff --git a/tests/plugins/search/subproject/search-link-to-overridden-subsubproject.bst b/tests/plugins/search/subproject/search-link-to-overridden-subsubproject.bst new file mode 100644 index 000000000..c97c55f9f --- /dev/null +++ b/tests/plugins/search/subproject/search-link-to-overridden-subsubproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subsubproject2.bst:target.bst + +config: + search: subsubproject2-target-link.bst diff --git a/tests/plugins/search/subproject/search-link-to-subsubproject.bst b/tests/plugins/search/subproject/search-link-to-subsubproject.bst new file mode 100644 index 000000000..dddb2e888 --- /dev/null +++ b/tests/plugins/search/subproject/search-link-to-subsubproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subsubproject.bst:target.bst + +config: + search: subsubproject-target-link.bst diff --git a/tests/plugins/search/subproject/search-link.bst b/tests/plugins/search/subproject/search-link.bst new file mode 100644 index 000000000..a2bfa95b3 --- /dev/null +++ b/tests/plugins/search/subproject/search-link.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- target.bst + +config: + search: target-link.bst diff --git a/tests/plugins/search/subproject/search-overridden-subsubproject.bst b/tests/plugins/search/subproject/search-overridden-subsubproject.bst new file mode 100644 index 000000000..dc6869b7f --- /dev/null +++ b/tests/plugins/search/subproject/search-overridden-subsubproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subsubproject2.bst:target.bst + +config: + search: subsubproject2.bst:target.bst diff --git a/tests/plugins/search/subproject/search-subsubproject.bst b/tests/plugins/search/subproject/search-subsubproject.bst new file mode 100644 index 000000000..4175db504 --- /dev/null +++ b/tests/plugins/search/subproject/search-subsubproject.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- subsubproject.bst:target.bst + +config: + search: subsubproject.bst:target.bst diff --git a/tests/plugins/search/subproject/search-target.bst b/tests/plugins/search/subproject/search-target.bst new file mode 100644 index 000000000..da594372f --- /dev/null +++ b/tests/plugins/search/subproject/search-target.bst @@ -0,0 +1,7 @@ +kind: search + +depends: +- target.bst + +config: + search: target.bst diff --git a/tests/plugins/search/subproject/sub.txt b/tests/plugins/search/subproject/sub.txt new file mode 100644 index 000000000..f73f3093f --- /dev/null +++ b/tests/plugins/search/subproject/sub.txt @@ -0,0 +1 @@ +file diff --git a/tests/plugins/search/subproject/subsubproject-target-link.bst b/tests/plugins/search/subproject/subsubproject-target-link.bst new file mode 100644 index 000000000..056b5244d --- /dev/null +++ b/tests/plugins/search/subproject/subsubproject-target-link.bst @@ -0,0 +1,4 @@ +kind: link + +config: + target: subsubproject.bst:target.bst diff --git a/tests/plugins/search/subproject/subsubproject.bst b/tests/plugins/search/subproject/subsubproject.bst new file mode 100644 index 000000000..f535ab0e0 --- /dev/null +++ b/tests/plugins/search/subproject/subsubproject.bst @@ -0,0 +1,4 @@ +kind: junction +sources: +- kind: local + path: subsubproject diff --git a/tests/plugins/search/subproject/subsubproject/project.conf b/tests/plugins/search/subproject/subsubproject/project.conf new file mode 100644 index 000000000..d11bcbb30 --- /dev/null +++ b/tests/plugins/search/subproject/subsubproject/project.conf @@ -0,0 +1,2 @@ +name: subsubtest +min-version: 2.0 diff --git a/tests/plugins/search/subproject/subsubproject/subsub.txt b/tests/plugins/search/subproject/subsubproject/subsub.txt new file mode 100644 index 000000000..f73f3093f --- /dev/null +++ b/tests/plugins/search/subproject/subsubproject/subsub.txt @@ -0,0 +1 @@ +file diff --git a/tests/plugins/search/subproject/subsubproject/target-link.bst b/tests/plugins/search/subproject/subsubproject/target-link.bst new file mode 100644 index 000000000..451ae0957 --- /dev/null +++ b/tests/plugins/search/subproject/subsubproject/target-link.bst @@ -0,0 +1,4 @@ +kind: link + +config: + target: target.bst diff --git a/tests/plugins/search/subproject/subsubproject/target.bst b/tests/plugins/search/subproject/subsubproject/target.bst new file mode 100644 index 000000000..afafac601 --- /dev/null +++ b/tests/plugins/search/subproject/subsubproject/target.bst @@ -0,0 +1,4 @@ +kind: import +sources: +- kind: local + path: subsub.txt diff --git a/tests/plugins/search/subproject/subsubproject2-target-link.bst b/tests/plugins/search/subproject/subsubproject2-target-link.bst new file mode 100644 index 000000000..6c44fe61a --- /dev/null +++ b/tests/plugins/search/subproject/subsubproject2-target-link.bst @@ -0,0 +1,4 @@ +kind: link + +config: + target: subsubproject2.bst:target.bst diff --git a/tests/plugins/search/subproject/subsubproject2.bst b/tests/plugins/search/subproject/subsubproject2.bst new file mode 100644 index 000000000..f535ab0e0 --- /dev/null +++ b/tests/plugins/search/subproject/subsubproject2.bst @@ -0,0 +1,4 @@ +kind: junction +sources: +- kind: local + path: subsubproject diff --git a/tests/plugins/search/subproject/target-link.bst b/tests/plugins/search/subproject/target-link.bst new file mode 100644 index 000000000..451ae0957 --- /dev/null +++ b/tests/plugins/search/subproject/target-link.bst @@ -0,0 +1,4 @@ +kind: link + +config: + target: target.bst diff --git a/tests/plugins/search/subproject/target.bst b/tests/plugins/search/subproject/target.bst new file mode 100644 index 000000000..e24d9bbb4 --- /dev/null +++ b/tests/plugins/search/subproject/target.bst @@ -0,0 +1,4 @@ +kind: import +sources: +- kind: local + path: sub.txt diff --git a/tests/plugins/search/subsubproject2.bst b/tests/plugins/search/subsubproject2.bst new file mode 100644 index 000000000..7dbf22a37 --- /dev/null +++ b/tests/plugins/search/subsubproject2.bst @@ -0,0 +1,4 @@ +kind: junction +sources: +- kind: local + path: subsubproject2 diff --git a/tests/plugins/search/subsubproject2/project.conf b/tests/plugins/search/subsubproject2/project.conf new file mode 100644 index 000000000..af0de9971 --- /dev/null +++ b/tests/plugins/search/subsubproject2/project.conf @@ -0,0 +1,2 @@ +name: subsubtest2 +min-version: 2.0 diff --git a/tests/plugins/search/subsubproject2/subsub.txt b/tests/plugins/search/subsubproject2/subsub.txt new file mode 100644 index 000000000..f73f3093f --- /dev/null +++ b/tests/plugins/search/subsubproject2/subsub.txt @@ -0,0 +1 @@ +file diff --git a/tests/plugins/search/subsubproject2/target-link.bst b/tests/plugins/search/subsubproject2/target-link.bst new file mode 100644 index 000000000..451ae0957 --- /dev/null +++ b/tests/plugins/search/subsubproject2/target-link.bst @@ -0,0 +1,4 @@ +kind: link + +config: + target: target.bst diff --git a/tests/plugins/search/subsubproject2/target.bst b/tests/plugins/search/subsubproject2/target.bst new file mode 100644 index 000000000..afafac601 --- /dev/null +++ b/tests/plugins/search/subsubproject2/target.bst @@ -0,0 +1,4 @@ +kind: import +sources: +- kind: local + path: subsub.txt |