diff options
-rw-r--r-- | src/buildstream/utils.py | 8 | ||||
-rw-r--r-- | tests/plugins/loading.py | 7 | ||||
-rw-r--r-- | tests/plugins/loading/plugins/elements/malformedminversion/badstring.py (renamed from tests/plugins/loading/plugins/elements/malformedminversion/malformedminversion.py) | 0 | ||||
-rw-r--r-- | tests/plugins/loading/plugins/elements/malformedminversion/dict.py | 11 | ||||
-rw-r--r-- | tests/plugins/loading/plugins/elements/malformedminversion/list.py | 11 | ||||
-rw-r--r-- | tests/plugins/loading/plugins/elements/malformedminversion/number.py | 11 | ||||
-rw-r--r-- | tests/plugins/loading/plugins/sources/malformedminversion/badstring.py (renamed from tests/plugins/loading/plugins/sources/malformedminversion/malformedminversion.py) | 0 | ||||
-rw-r--r-- | tests/plugins/loading/plugins/sources/malformedminversion/dict.py | 11 | ||||
-rw-r--r-- | tests/plugins/loading/plugins/sources/malformedminversion/list.py | 11 | ||||
-rw-r--r-- | tests/plugins/loading/plugins/sources/malformedminversion/number.py | 11 |
10 files changed, 74 insertions, 7 deletions
diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py index 9f7690f7f..29b3bf484 100644 --- a/src/buildstream/utils.py +++ b/src/buildstream/utils.py @@ -1598,14 +1598,14 @@ def _is_single_threaded(): # def _parse_version(version: str) -> Tuple[int, int]: - versions = version.split(".") try: + versions = version.split(".") major = int(versions[0]) minor = int(versions[1]) - except (IndexError, ValueError): - raise UtilError("Malformed version string: {}".format(version),) + except (IndexError, ValueError, AttributeError) as e: + raise UtilError("Malformed version string: {}".format(version),) from e - return (major, minor) + return major, minor # _get_bst_api_version(): diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py index 13d787b0e..bbb6c7e4d 100644 --- a/tests/plugins/loading.py +++ b/tests/plugins/loading.py @@ -166,7 +166,8 @@ def test_missing_min_version(cli, datafiles, plugin_type): @pytest.mark.datafiles(DATA_DIR) @pytest.mark.parametrize("plugin_type", [("elements"), ("sources")]) -def test_malformed_min_version(cli, datafiles, plugin_type): +@pytest.mark.parametrize("plugin", [("badstring"), ("number"), ("dict"), ("list")]) +def test_malformed_min_version(cli, datafiles, plugin_type, plugin): project = str(datafiles) update_project( @@ -176,12 +177,12 @@ def test_malformed_min_version(cli, datafiles, plugin_type): { "origin": "local", "path": os.path.join("plugins", plugin_type, "malformedminversion"), - plugin_type: ["malformedminversion"], + plugin_type: [plugin], } ] }, ) - setup_element(project, plugin_type, "malformedminversion") + setup_element(project, plugin_type, plugin) result = cli.run(project=project, args=["show", "element.bst"]) result.assert_main_error(ErrorDomain.PLUGIN, "malformed-min-version") diff --git a/tests/plugins/loading/plugins/elements/malformedminversion/malformedminversion.py b/tests/plugins/loading/plugins/elements/malformedminversion/badstring.py index 5f96c1897..5f96c1897 100644 --- a/tests/plugins/loading/plugins/elements/malformedminversion/malformedminversion.py +++ b/tests/plugins/loading/plugins/elements/malformedminversion/badstring.py diff --git a/tests/plugins/loading/plugins/elements/malformedminversion/dict.py b/tests/plugins/loading/plugins/elements/malformedminversion/dict.py new file mode 100644 index 000000000..1ee2e52f4 --- /dev/null +++ b/tests/plugins/loading/plugins/elements/malformedminversion/dict.py @@ -0,0 +1,11 @@ +# Plugins are required to specify the BST_MIN_VERSION +from buildstream import Element + + +class MalformedMinVersion(Element): + + BST_MIN_VERSION = {"major": 2, "minor": 0} + + +def setup(): + return MalformedMinVersion diff --git a/tests/plugins/loading/plugins/elements/malformedminversion/list.py b/tests/plugins/loading/plugins/elements/malformedminversion/list.py new file mode 100644 index 000000000..c92224969 --- /dev/null +++ b/tests/plugins/loading/plugins/elements/malformedminversion/list.py @@ -0,0 +1,11 @@ +# Plugins are required to specify the BST_MIN_VERSION +from buildstream import Element + + +class MalformedMinVersion(Element): + + BST_MIN_VERSION = [2, 0] + + +def setup(): + return MalformedMinVersion diff --git a/tests/plugins/loading/plugins/elements/malformedminversion/number.py b/tests/plugins/loading/plugins/elements/malformedminversion/number.py new file mode 100644 index 000000000..154f16d33 --- /dev/null +++ b/tests/plugins/loading/plugins/elements/malformedminversion/number.py @@ -0,0 +1,11 @@ +# Plugins are required to specify the BST_MIN_VERSION +from buildstream import Element + + +class MalformedMinVersion(Element): + + BST_MIN_VERSION = 2.0 + + +def setup(): + return MalformedMinVersion diff --git a/tests/plugins/loading/plugins/sources/malformedminversion/malformedminversion.py b/tests/plugins/loading/plugins/sources/malformedminversion/badstring.py index 90474597c..90474597c 100644 --- a/tests/plugins/loading/plugins/sources/malformedminversion/malformedminversion.py +++ b/tests/plugins/loading/plugins/sources/malformedminversion/badstring.py diff --git a/tests/plugins/loading/plugins/sources/malformedminversion/dict.py b/tests/plugins/loading/plugins/sources/malformedminversion/dict.py new file mode 100644 index 000000000..4df4d5297 --- /dev/null +++ b/tests/plugins/loading/plugins/sources/malformedminversion/dict.py @@ -0,0 +1,11 @@ +# Plugins are required to specify the BST_MIN_VERSION +from buildstream import Source + + +class MalformedMinVersion(Source): + + BST_MIN_VERSION = {"major": 2, "minor": 0} + + +def setup(): + return MalformedMinVersion diff --git a/tests/plugins/loading/plugins/sources/malformedminversion/list.py b/tests/plugins/loading/plugins/sources/malformedminversion/list.py new file mode 100644 index 000000000..a3bcf1928 --- /dev/null +++ b/tests/plugins/loading/plugins/sources/malformedminversion/list.py @@ -0,0 +1,11 @@ +# Plugins are required to specify the BST_MIN_VERSION +from buildstream import Source + + +class MalformedMinVersion(Source): + + BST_MIN_VERSION = [2, 0] + + +def setup(): + return MalformedMinVersion diff --git a/tests/plugins/loading/plugins/sources/malformedminversion/number.py b/tests/plugins/loading/plugins/sources/malformedminversion/number.py new file mode 100644 index 000000000..1d1517945 --- /dev/null +++ b/tests/plugins/loading/plugins/sources/malformedminversion/number.py @@ -0,0 +1,11 @@ +# Plugins are required to specify the BST_MIN_VERSION +from buildstream import Source + + +class MalformedMinVersion(Source): + + BST_MIN_VERSION = 2.0 + + +def setup(): + return MalformedMinVersion |