summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-04-29 16:22:43 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-05-03 13:30:13 +0900
commite13275bdd92aae182d7e93f5b916c4fc4fd280f8 (patch)
treec26663281b60901ddd26e7303b4dc90fe947e338
parent9084ae13d1872a21ae1a3298f44e192e7cf7ca8a (diff)
downloadbuildstream-e13275bdd92aae182d7e93f5b916c4fc4fd280f8.tar.gz
tests/plugins/loading.py: Migrate tests for found/not found plugins
This new test replaces the test in tests/format/project.py.
-rw-r--r--tests/format/project.py14
-rw-r--r--tests/format/project/plugin-allowed/__init__.py0
-rw-r--r--tests/format/project/plugin-allowed/element.bst1
-rw-r--r--tests/format/project/plugin-allowed/plugins/__init__.py0
-rw-r--r--tests/format/project/plugin-allowed/plugins/foo.py19
-rw-r--r--tests/format/project/plugin-allowed/project.conf8
-rw-r--r--tests/format/project/plugin-forbidden/__init__.py0
-rw-r--r--tests/format/project/plugin-forbidden/element.bst1
-rw-r--r--tests/format/project/plugin-forbidden/forbidden-plugins/__init__.py0
-rw-r--r--tests/format/project/plugin-forbidden/project.conf3
-rw-r--r--tests/plugins/loading.py30
-rw-r--r--tests/plugins/loading/plugins/elements/found/found.py (renamed from tests/format/project/plugin-forbidden/forbidden-plugins/forbidden-plugin.py)10
-rw-r--r--tests/plugins/loading/plugins/sources/found/found.py32
13 files changed, 67 insertions, 51 deletions
diff --git a/tests/format/project.py b/tests/format/project.py
index 32c5d81e5..d3de67222 100644
--- a/tests/format/project.py
+++ b/tests/format/project.py
@@ -153,20 +153,6 @@ def test_local_plugin_not_directory(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
-def test_plugin_load_allowed(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, "plugin-allowed")
- result = cli.run(project=project, silent=True, args=["show", "element.bst"])
- result.assert_success()
-
-
-@pytest.mark.datafiles(DATA_DIR)
-def test_plugin_load_forbidden(cli, datafiles):
- project = os.path.join(datafiles.dirname, datafiles.basename, "plugin-forbidden")
- result = cli.run(project=project, silent=True, args=["show", "element.bst"])
- result.assert_main_error(ErrorDomain.PLUGIN, "plugin-not-found")
-
-
-@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("ref_storage", [("inline"), ("project.refs")])
def test_plugin_no_load_ref(cli, datafiles, ref_storage):
project = os.path.join(datafiles.dirname, datafiles.basename, "plugin-no-load-ref")
diff --git a/tests/format/project/plugin-allowed/__init__.py b/tests/format/project/plugin-allowed/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/format/project/plugin-allowed/__init__.py
+++ /dev/null
diff --git a/tests/format/project/plugin-allowed/element.bst b/tests/format/project/plugin-allowed/element.bst
deleted file mode 100644
index 675938bec..000000000
--- a/tests/format/project/plugin-allowed/element.bst
+++ /dev/null
@@ -1 +0,0 @@
-kind: foo
diff --git a/tests/format/project/plugin-allowed/plugins/__init__.py b/tests/format/project/plugin-allowed/plugins/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/format/project/plugin-allowed/plugins/__init__.py
+++ /dev/null
diff --git a/tests/format/project/plugin-allowed/plugins/foo.py b/tests/format/project/plugin-allowed/plugins/foo.py
deleted file mode 100644
index 76d9bfd3c..000000000
--- a/tests/format/project/plugin-allowed/plugins/foo.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from buildstream import Element
-
-
-class FooElement(Element):
-
- BST_MIN_VERSION = "2.0"
-
- def configure(self, config):
- pass
-
- def preflight(self):
- pass
-
- def get_unique_key(self):
- return "foo"
-
-
-def setup():
- return FooElement
diff --git a/tests/format/project/plugin-allowed/project.conf b/tests/format/project/plugin-allowed/project.conf
deleted file mode 100644
index 97107edf6..000000000
--- a/tests/format/project/plugin-allowed/project.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-name: test
-min-version: 2.0
-
-plugins:
-- origin: local
- path: plugins
- elements:
- - foo
diff --git a/tests/format/project/plugin-forbidden/__init__.py b/tests/format/project/plugin-forbidden/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/format/project/plugin-forbidden/__init__.py
+++ /dev/null
diff --git a/tests/format/project/plugin-forbidden/element.bst b/tests/format/project/plugin-forbidden/element.bst
deleted file mode 100644
index c8d51318c..000000000
--- a/tests/format/project/plugin-forbidden/element.bst
+++ /dev/null
@@ -1 +0,0 @@
-kind: bar
diff --git a/tests/format/project/plugin-forbidden/forbidden-plugins/__init__.py b/tests/format/project/plugin-forbidden/forbidden-plugins/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/format/project/plugin-forbidden/forbidden-plugins/__init__.py
+++ /dev/null
diff --git a/tests/format/project/plugin-forbidden/project.conf b/tests/format/project/plugin-forbidden/project.conf
deleted file mode 100644
index 0211b2061..000000000
--- a/tests/format/project/plugin-forbidden/project.conf
+++ /dev/null
@@ -1,3 +0,0 @@
-name: test
-min-version: 2.0
-
diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py
index a368e9952..a54df776e 100644
--- a/tests/plugins/loading.py
+++ b/tests/plugins/loading.py
@@ -200,3 +200,33 @@ def test_incompatible_minor_version(cli, datafiles, plugin_type):
result = cli.run(project=project, args=["show", "element.bst"])
result.assert_main_error(ErrorDomain.PLUGIN, "incompatible-minor-version")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_plugin_not_found(cli, datafiles, plugin_type):
+ project = str(datafiles)
+
+ setup_element(project, plugin_type, "notfound")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_main_error(ErrorDomain.PLUGIN, "plugin-not-found")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_plugin_found(cli, datafiles, plugin_type):
+ project = str(datafiles)
+
+ update_project(
+ project,
+ {
+ "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()
diff --git a/tests/format/project/plugin-forbidden/forbidden-plugins/forbidden-plugin.py b/tests/plugins/loading/plugins/elements/found/found.py
index 76d9bfd3c..34a7e4398 100644
--- a/tests/format/project/plugin-forbidden/forbidden-plugins/forbidden-plugin.py
+++ b/tests/plugins/loading/plugins/elements/found/found.py
@@ -1,19 +1,19 @@
from buildstream import Element
-class FooElement(Element):
-
+class Found(Element):
BST_MIN_VERSION = "2.0"
- def configure(self, config):
+ def configure(self, node):
pass
def preflight(self):
pass
def get_unique_key(self):
- return "foo"
+ return {}
+# Plugin entry point
def setup():
- return FooElement
+ return Found
diff --git a/tests/plugins/loading/plugins/sources/found/found.py b/tests/plugins/loading/plugins/sources/found/found.py
new file mode 100644
index 000000000..4ab40f005
--- /dev/null
+++ b/tests/plugins/loading/plugins/sources/found/found.py
@@ -0,0 +1,32 @@
+from buildstream import Source
+
+
+class Found(Source):
+ BST_MIN_VERSION = "2.0"
+
+ def configure(self, node):
+ pass
+
+ def preflight(self):
+ pass
+
+ def get_unique_key(self):
+ return {}
+
+ def load_ref(self, node):
+ pass
+
+ def get_ref(self):
+ return {}
+
+ def set_ref(self, ref, node):
+ pass
+
+ def is_cached(self):
+ return False
+
+
+# Plugin entry point
+def setup():
+
+ return Found