summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-04-28 19:15:59 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-04-29 16:24:59 +0900
commitfdaf73f62b8c340f1a13dd20c6c65702ec09716f (patch)
tree73187a76653b369cfec3e2b3d7d72a026c68b279
parenta311a14f4b0a649b5f872ab020885b0a1d6e09d1 (diff)
downloadbuildstream-fdaf73f62b8c340f1a13dd20c6c65702ec09716f.tar.gz
tests/plugins/loading.py: Added tests for plugin BST_MIN_VERSION guards
-rw-r--r--setup.cfg2
-rw-r--r--tests/plugins/loading.py92
-rw-r--r--tests/plugins/loading/plugins/elements/incompatiblemajor/incompatiblemajor.py10
-rw-r--r--tests/plugins/loading/plugins/elements/incompatibleminor/incompatibleminor.py10
-rw-r--r--tests/plugins/loading/plugins/elements/malformedminversion/malformedminversion.py11
-rw-r--r--tests/plugins/loading/plugins/elements/nominversion/nominversion.py10
-rw-r--r--tests/plugins/loading/plugins/sources/incompatiblemajor/incompatiblemajor.py10
-rw-r--r--tests/plugins/loading/plugins/sources/incompatibleminor/incompatibleminor.py10
-rw-r--r--tests/plugins/loading/plugins/sources/malformedminversion/malformedminversion.py11
-rw-r--r--tests/plugins/loading/plugins/sources/nominversion/nominversion.py10
10 files changed, 175 insertions, 1 deletions
diff --git a/setup.cfg b/setup.cfg
index 7d3599e14..0853264f6 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,7 +9,7 @@ parentdir_prefix = BuildStream-
[tool:pytest]
addopts = --verbose --basetemp ./tmp --durations=20 --timeout=1800
-norecursedirs = src tests/integration/project integration-cache tmp __pycache__ .eggs
+norecursedirs = src tests/integration/project tests/plugins/loading integration-cache tmp __pycache__ .eggs
python_files = tests/*/*.py
env =
D:BST_TEST_SUITE=True
diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py
index 1c8a321d5..a368e9952 100644
--- a/tests/plugins/loading.py
+++ b/tests/plugins/loading.py
@@ -108,3 +108,95 @@ def test_setup_returns_bad_type(cli, datafiles, plugin_type):
result = cli.run(project=project, args=["show", "element.bst"])
result.assert_main_error(ErrorDomain.PLUGIN, "setup-returns-bad-type")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_missing_min_version(cli, datafiles, plugin_type):
+ project = str(datafiles)
+
+ update_project(
+ project,
+ {
+ "plugins": [
+ {
+ "origin": "local",
+ "path": os.path.join("plugins", plugin_type, "nominversion"),
+ plugin_type: ["nominversion"],
+ }
+ ]
+ },
+ )
+ setup_element(project, plugin_type, "nominversion")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_main_error(ErrorDomain.PLUGIN, "missing-min-version")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_malformed_min_version(cli, datafiles, plugin_type):
+ project = str(datafiles)
+
+ update_project(
+ project,
+ {
+ "plugins": [
+ {
+ "origin": "local",
+ "path": os.path.join("plugins", plugin_type, "malformedminversion"),
+ plugin_type: ["malformedminversion"],
+ }
+ ]
+ },
+ )
+ setup_element(project, plugin_type, "malformedminversion")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_main_error(ErrorDomain.PLUGIN, "malformed-min-version")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_incompatible_major_version(cli, datafiles, plugin_type):
+ project = str(datafiles)
+
+ update_project(
+ project,
+ {
+ "plugins": [
+ {
+ "origin": "local",
+ "path": os.path.join("plugins", plugin_type, "incompatiblemajor"),
+ plugin_type: ["incompatiblemajor"],
+ }
+ ]
+ },
+ )
+ setup_element(project, plugin_type, "incompatiblemajor")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_main_error(ErrorDomain.PLUGIN, "incompatible-major-version")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")])
+def test_incompatible_minor_version(cli, datafiles, plugin_type):
+ project = str(datafiles)
+
+ update_project(
+ project,
+ {
+ "plugins": [
+ {
+ "origin": "local",
+ "path": os.path.join("plugins", plugin_type, "incompatibleminor"),
+ plugin_type: ["incompatibleminor"],
+ }
+ ]
+ },
+ )
+ setup_element(project, plugin_type, "incompatibleminor")
+
+ result = cli.run(project=project, args=["show", "element.bst"])
+ result.assert_main_error(ErrorDomain.PLUGIN, "incompatible-minor-version")
diff --git a/tests/plugins/loading/plugins/elements/incompatiblemajor/incompatiblemajor.py b/tests/plugins/loading/plugins/elements/incompatiblemajor/incompatiblemajor.py
new file mode 100644
index 000000000..a0ea59309
--- /dev/null
+++ b/tests/plugins/loading/plugins/elements/incompatiblemajor/incompatiblemajor.py
@@ -0,0 +1,10 @@
+from buildstream import Element
+
+
+class IncompatibleMajor(Element):
+
+ BST_MIN_VERSION = "1.0"
+
+
+def setup():
+ return IncompatibleMajor
diff --git a/tests/plugins/loading/plugins/elements/incompatibleminor/incompatibleminor.py b/tests/plugins/loading/plugins/elements/incompatibleminor/incompatibleminor.py
new file mode 100644
index 000000000..d9967caaa
--- /dev/null
+++ b/tests/plugins/loading/plugins/elements/incompatibleminor/incompatibleminor.py
@@ -0,0 +1,10 @@
+from buildstream import Element
+
+
+class IncompatibleMinor(Element):
+
+ BST_MIN_VERSION = "2.1000"
+
+
+def setup():
+ return IncompatibleMinor
diff --git a/tests/plugins/loading/plugins/elements/malformedminversion/malformedminversion.py b/tests/plugins/loading/plugins/elements/malformedminversion/malformedminversion.py
new file mode 100644
index 000000000..5f96c1897
--- /dev/null
+++ b/tests/plugins/loading/plugins/elements/malformedminversion/malformedminversion.py
@@ -0,0 +1,11 @@
+# Plugins are required to specify the BST_MIN_VERSION
+from buildstream import Element
+
+
+class MalformedMinVersion(Element):
+
+ BST_MIN_VERSION = "1.pony"
+
+
+def setup():
+ return MalformedMinVersion
diff --git a/tests/plugins/loading/plugins/elements/nominversion/nominversion.py b/tests/plugins/loading/plugins/elements/nominversion/nominversion.py
new file mode 100644
index 000000000..e3f5b0cb6
--- /dev/null
+++ b/tests/plugins/loading/plugins/elements/nominversion/nominversion.py
@@ -0,0 +1,10 @@
+# Plugins are required to specify the BST_MIN_VERSION
+from buildstream import Element
+
+
+class NoMinVersion(Element):
+ pass
+
+
+def setup():
+ return NoMinVersion
diff --git a/tests/plugins/loading/plugins/sources/incompatiblemajor/incompatiblemajor.py b/tests/plugins/loading/plugins/sources/incompatiblemajor/incompatiblemajor.py
new file mode 100644
index 000000000..f2d088b77
--- /dev/null
+++ b/tests/plugins/loading/plugins/sources/incompatiblemajor/incompatiblemajor.py
@@ -0,0 +1,10 @@
+from buildstream import Source
+
+
+class IncompatibleMajor(Source):
+
+ BST_MIN_VERSION = "1.0"
+
+
+def setup():
+ return IncompatibleMajor
diff --git a/tests/plugins/loading/plugins/sources/incompatibleminor/incompatibleminor.py b/tests/plugins/loading/plugins/sources/incompatibleminor/incompatibleminor.py
new file mode 100644
index 000000000..2282534ae
--- /dev/null
+++ b/tests/plugins/loading/plugins/sources/incompatibleminor/incompatibleminor.py
@@ -0,0 +1,10 @@
+from buildstream import Source
+
+
+class IncompatibleMinor(Source):
+
+ BST_MIN_VERSION = "2.1000"
+
+
+def setup():
+ return IncompatibleMinor
diff --git a/tests/plugins/loading/plugins/sources/malformedminversion/malformedminversion.py b/tests/plugins/loading/plugins/sources/malformedminversion/malformedminversion.py
new file mode 100644
index 000000000..90474597c
--- /dev/null
+++ b/tests/plugins/loading/plugins/sources/malformedminversion/malformedminversion.py
@@ -0,0 +1,11 @@
+# Plugins are required to specify the BST_MIN_VERSION
+from buildstream import Source
+
+
+class MalformedMinVersion(Source):
+
+ BST_MIN_VERSION = "1.pony"
+
+
+def setup():
+ return MalformedMinVersion
diff --git a/tests/plugins/loading/plugins/sources/nominversion/nominversion.py b/tests/plugins/loading/plugins/sources/nominversion/nominversion.py
new file mode 100644
index 000000000..12cdfa296
--- /dev/null
+++ b/tests/plugins/loading/plugins/sources/nominversion/nominversion.py
@@ -0,0 +1,10 @@
+# Plugins are required to specify the BST_MIN_VERSION
+from buildstream import Source
+
+
+class NoMinVersion(Source):
+ pass
+
+
+def setup():
+ return NoMinVersion