summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan van Berkom <tristan.vanberkom@codethink.co.uk>2020-05-21 18:36:06 +0900
committerTristan van Berkom <tristan.vanberkom@codethink.co.uk>2020-05-28 15:02:23 +0900
commit37d680f0545b0336005e48f02c676eb9ba9a566e (patch)
tree68c40a4ef66ac53f6b664914c5e014678613fa54
parentec91f1faa31ae59bdbdbd7202953a7c3a1099e59 (diff)
downloadbuildstream-37d680f0545b0336005e48f02c676eb9ba9a566e.tar.gz
tests/plugins/loading.py: Adding tests for junction plugin origin
-rw-r--r--tests/plugins/loading.py170
-rw-r--r--tests/plugins/loading/elements/subproject-junction.bst5
-rw-r--r--tests/plugins/loading/subproject/elements/subsubproject-junction.bst5
-rw-r--r--tests/plugins/loading/subproject/project.conf8
-rw-r--r--tests/plugins/loading/subproject/subsubproject/project.conf5
5 files changed, 193 insertions, 0 deletions
diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py
index bbb6c7e4d..63a2ca3d4 100644
--- a/tests/plugins/loading.py
+++ b/tests/plugins/loading.py
@@ -7,6 +7,7 @@
#
import os
+import shutil
import pytest
from buildstream.exceptions import ErrorDomain
@@ -429,3 +430,172 @@ def test_pip_origin_malformed_constraints(cli, datafiles, plugin_type):
result = cli.run(project=project, args=["show", "element.bst"])
result.assert_main_error(ErrorDomain.PLUGIN, "package-malformed-requirement")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_junction_plugin_found(cli, datafiles, plugin_type):
+ project = str(datafiles)
+ subproject = os.path.join(project, "subproject")
+
+ shutil.copytree(os.path.join(project, "plugins"), os.path.join(subproject, "plugins"))
+
+ update_project(
+ project, {"plugins": [{"origin": "junction", "junction": "subproject-junction.bst", plugin_type: ["found"],}]},
+ )
+ update_project(
+ subproject,
+ {
+ "plugins": [
+ {"origin": "local", "path": os.path.join("plugins", plugin_type, "found"), plugin_type: ["found"],}
+ ]
+ },
+ )
+ setup_element(project, plugin_type, "found")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_success()
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_junction_plugin_not_found(cli, datafiles, plugin_type):
+ project = str(datafiles)
+ subproject = os.path.join(project, "subproject")
+
+ shutil.copytree(os.path.join(project, "plugins"), os.path.join(subproject, "plugins"))
+
+ # The toplevel says to search for the "notfound" plugin in the subproject
+ #
+ update_project(
+ project,
+ {"plugins": [{"origin": "junction", "junction": "subproject-junction.bst", plugin_type: ["notfound"],}]},
+ )
+
+ # The subproject only configures the "found" plugin
+ #
+ update_project(
+ subproject,
+ {
+ "plugins": [
+ {"origin": "local", "path": os.path.join("plugins", plugin_type, "found"), plugin_type: ["found"],}
+ ]
+ },
+ )
+ setup_element(project, plugin_type, "notfound")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_main_error(ErrorDomain.PLUGIN, "junction-plugin-not-found")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_junction_deep_plugin_found(cli, datafiles, plugin_type):
+ project = str(datafiles)
+ subproject = os.path.join(project, "subproject")
+ subsubproject = os.path.join(subproject, "subsubproject")
+
+ shutil.copytree(os.path.join(project, "plugins"), os.path.join(subsubproject, "plugins"))
+
+ update_project(
+ project, {"plugins": [{"origin": "junction", "junction": "subproject-junction.bst", plugin_type: ["found"],}]},
+ )
+ update_project(
+ subproject,
+ {"plugins": [{"origin": "junction", "junction": "subsubproject-junction.bst", plugin_type: ["found"],}]},
+ )
+ update_project(
+ subsubproject,
+ {
+ "plugins": [
+ {"origin": "local", "path": os.path.join("plugins", plugin_type, "found"), plugin_type: ["found"],}
+ ]
+ },
+ )
+ setup_element(project, plugin_type, "found")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_success()
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_junction_deep_plugin_not_found(cli, datafiles, plugin_type):
+ project = str(datafiles)
+ subproject = os.path.join(project, "subproject")
+ subsubproject = os.path.join(subproject, "subsubproject")
+
+ shutil.copytree(os.path.join(project, "plugins"), os.path.join(subsubproject, "plugins"))
+
+ # The toplevel says to search for the "notfound" plugin in the subproject
+ #
+ update_project(
+ project,
+ {"plugins": [{"origin": "junction", "junction": "subproject-junction.bst", plugin_type: ["notfound"],}]},
+ )
+
+ # The subproject says to search for the "notfound" plugin in the subproject
+ #
+ update_project(
+ subproject,
+ {"plugins": [{"origin": "junction", "junction": "subsubproject-junction.bst", plugin_type: ["notfound"],}]},
+ )
+
+ # The subsubproject only configures the "found" plugin
+ #
+ update_project(
+ subsubproject,
+ {
+ "plugins": [
+ {"origin": "local", "path": os.path.join("plugins", plugin_type, "found"), plugin_type: ["found"],}
+ ]
+ },
+ )
+ setup_element(project, plugin_type, "notfound")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_main_error(ErrorDomain.PLUGIN, "junction-plugin-load-error")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+@pytest.mark.skipif("not pip_sample_packages()", reason=SAMPLE_PACKAGES_SKIP_REASON)
+def test_junction_pip_plugin_found(cli, datafiles, plugin_type):
+ project = str(datafiles)
+ subproject = os.path.join(project, "subproject")
+
+ shutil.copytree(os.path.join(project, "plugins"), os.path.join(subproject, "plugins"))
+
+ update_project(
+ project,
+ {"plugins": [{"origin": "junction", "junction": "subproject-junction.bst", plugin_type: ["sample"],}]},
+ )
+ update_project(
+ subproject, {"plugins": [{"origin": "pip", "package-name": "sample-plugins", plugin_type: ["sample"],}]},
+ )
+ setup_element(project, plugin_type, "sample")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_success()
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+@pytest.mark.skipif("not pip_sample_packages()", reason=SAMPLE_PACKAGES_SKIP_REASON)
+def test_junction_pip_plugin_version_conflict(cli, datafiles, plugin_type):
+ project = str(datafiles)
+ subproject = os.path.join(project, "subproject")
+
+ shutil.copytree(os.path.join(project, "plugins"), os.path.join(subproject, "plugins"))
+
+ update_project(
+ project,
+ {"plugins": [{"origin": "junction", "junction": "subproject-junction.bst", plugin_type: ["sample"],}]},
+ )
+ update_project(
+ subproject, {"plugins": [{"origin": "pip", "package-name": "sample-plugins>=1.4", plugin_type: ["sample"],}]},
+ )
+ setup_element(project, plugin_type, "sample")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_main_error(ErrorDomain.PLUGIN, "junction-plugin-load-error")
diff --git a/tests/plugins/loading/elements/subproject-junction.bst b/tests/plugins/loading/elements/subproject-junction.bst
new file mode 100644
index 000000000..6664eeec6
--- /dev/null
+++ b/tests/plugins/loading/elements/subproject-junction.bst
@@ -0,0 +1,5 @@
+kind: junction
+
+sources:
+- kind: local
+ path: subproject
diff --git a/tests/plugins/loading/subproject/elements/subsubproject-junction.bst b/tests/plugins/loading/subproject/elements/subsubproject-junction.bst
new file mode 100644
index 000000000..018fb8ec4
--- /dev/null
+++ b/tests/plugins/loading/subproject/elements/subsubproject-junction.bst
@@ -0,0 +1,5 @@
+kind: junction
+
+sources:
+- kind: local
+ path: subsubproject
diff --git a/tests/plugins/loading/subproject/project.conf b/tests/plugins/loading/subproject/project.conf
new file mode 100644
index 000000000..cfd8010fc
--- /dev/null
+++ b/tests/plugins/loading/subproject/project.conf
@@ -0,0 +1,8 @@
+# The subproject test
+name: subtest
+
+# Required BuildStream version
+min-version: 2.0
+
+# Subdirectory where elements are stored
+element-path: elements
diff --git a/tests/plugins/loading/subproject/subsubproject/project.conf b/tests/plugins/loading/subproject/subsubproject/project.conf
new file mode 100644
index 000000000..3d8f93ebd
--- /dev/null
+++ b/tests/plugins/loading/subproject/subsubproject/project.conf
@@ -0,0 +1,5 @@
+# The subproject test
+name: subsubtest
+
+# Required BuildStream version
+min-version: 2.0