summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-04-24 18:12:54 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-04-29 16:24:58 +0900
commitd63bd7e9def528d3ed59a2798452ac1da58ebea4 (patch)
tree05153205e2d5fa8644af7d877319a3cbc0566b68
parent82eb1d4271bb634f248bc9e1770119d2815d7cd6 (diff)
downloadbuildstream-d63bd7e9def528d3ed59a2798452ac1da58ebea4.tar.gz
Plugin loading refactor, removing all versioning
Plugin format versioning was decided to be removed for local plugins and any plugins for which we do not load an explicitly provided plugin. For pip, this will be handled with a standard distutils/setuptools approach, allowing users to specify pip style version boundaries in the plugin origins. This patch refactors plugin loading so that all related code goes into the private _pluginfactory module, a new small PluginOrigin type was added to better manipulate loaded origins. Test cases have been removed and will be readded in a following commit, adjusted to new expectations.
-rw-r--r--doc/examples/flatpak-autotools/project.conf2
-rw-r--r--src/buildstream/_pluginfactory/__init__.py20
-rw-r--r--src/buildstream/_pluginfactory/elementfactory.py (renamed from src/buildstream/_elementfactory.py)21
-rw-r--r--src/buildstream/_pluginfactory/pluginfactory.py (renamed from src/buildstream/_plugincontext.py)119
-rw-r--r--src/buildstream/_pluginfactory/pluginorigin.py130
-rw-r--r--src/buildstream/_pluginfactory/sourcefactory.py (renamed from src/buildstream/_sourcefactory.py)21
-rw-r--r--src/buildstream/_project.py101
-rw-r--r--src/buildstream/plugin.py21
-rw-r--r--src/buildstream/testing/_sourcetests/utils.py2
-rw-r--r--tests/elements/filter/basic/project.conf2
-rw-r--r--tests/format/project.py4
-rw-r--r--tests/format/project/duplicate-plugins/project.conf8
-rw-r--r--tests/format/project/local-plugin/project.conf2
-rw-r--r--tests/format/project/plugin-allowed/project.conf2
-rw-r--r--tests/format/project/plugin-preflight-error/project.conf2
-rw-r--r--tests/frontend/configurable_warnings.py4
-rw-r--r--tests/frontend/configuredwarning/project.conf4
-rw-r--r--tests/frontend/consistencyerror/project.conf4
-rw-r--r--tests/frontend/mirror.py2
-rw-r--r--tests/frontend/push.py2
-rw-r--r--tests/internals/pluginfactory.py287
-rw-r--r--tests/internals/pluginfactory/anotherelement/__init__.py0
-rw-r--r--tests/internals/pluginfactory/anotherelement/foo.py9
-rw-r--r--tests/internals/pluginfactory/anothersource/__init__.py0
-rw-r--r--tests/internals/pluginfactory/anothersource/foo.py9
-rw-r--r--tests/internals/pluginfactory/badsetup/__init__.py0
-rw-r--r--tests/internals/pluginfactory/badsetup/foo.py6
-rw-r--r--tests/internals/pluginfactory/badversionelement/__init__.py0
-rw-r--r--tests/internals/pluginfactory/badversionelement/foo.py11
-rw-r--r--tests/internals/pluginfactory/badversionsource/__init__.py0
-rw-r--r--tests/internals/pluginfactory/badversionsource/foo.py11
-rw-r--r--tests/internals/pluginfactory/customelement/__init__.py0
-rw-r--r--tests/internals/pluginfactory/customelement/foo.py9
-rw-r--r--tests/internals/pluginfactory/customsource/__init__.py0
-rw-r--r--tests/internals/pluginfactory/customsource/foo.py9
-rw-r--r--tests/internals/pluginfactory/nosetup/__init__.py0
-rw-r--r--tests/internals/pluginfactory/nosetup/foo.py8
-rw-r--r--tests/internals/pluginfactory/notatype/__init__.py0
-rw-r--r--tests/internals/pluginfactory/notatype/foo.py6
-rw-r--r--tests/internals/pluginfactory/wrongtype/__init__.py0
-rw-r--r--tests/internals/pluginfactory/wrongtype/foo.py12
-rw-r--r--tests/internals/pluginloading.py22
-rw-r--r--tests/internals/pluginloading/badversionelement/customelements/__init__.py0
-rw-r--r--tests/internals/pluginloading/badversionelement/customelements/foo.py19
-rw-r--r--tests/internals/pluginloading/badversionelement/elements/simple.bst4
-rw-r--r--tests/internals/pluginloading/badversionelement/project.conf10
-rw-r--r--tests/internals/pluginloading/badversionsource/customsources/__init__.py0
-rw-r--r--tests/internals/pluginloading/badversionsource/customsources/foo.py16
-rw-r--r--tests/internals/pluginloading/badversionsource/elements/simple.bst6
-rw-r--r--tests/internals/pluginloading/badversionsource/project.conf10
-rw-r--r--tests/internals/pluginloading/customelement/project.conf2
-rw-r--r--tests/internals/pluginloading/customsource/project.conf2
-rw-r--r--tests/plugins/deprecationwarnings/project/project.conf2
-rw-r--r--tests/sourcecache/project/project.conf2
-rw-r--r--tests/sources/no-fetch-cached/project.conf2
-rw-r--r--tests/sources/previous_source_access/project.conf2
-rw-r--r--tests/sources/project_key_test/project.conf2
57 files changed, 244 insertions, 707 deletions
diff --git a/doc/examples/flatpak-autotools/project.conf b/doc/examples/flatpak-autotools/project.conf
index 08dc6ee32..d7a0a396d 100644
--- a/doc/examples/flatpak-autotools/project.conf
+++ b/doc/examples/flatpak-autotools/project.conf
@@ -19,4 +19,4 @@ plugins:
- origin: pip
package-name: bst-plugins-experimental
sources:
- ostree: 0
+ - ostree
diff --git a/src/buildstream/_pluginfactory/__init__.py b/src/buildstream/_pluginfactory/__init__.py
new file mode 100644
index 000000000..fe69b6e77
--- /dev/null
+++ b/src/buildstream/_pluginfactory/__init__.py
@@ -0,0 +1,20 @@
+#
+# Copyright (C) 2020 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+#
+
+from .pluginorigin import PluginOrigin, PluginOriginType
+from .sourcefactory import SourceFactory
+from .elementfactory import ElementFactory
diff --git a/src/buildstream/_elementfactory.py b/src/buildstream/_pluginfactory/elementfactory.py
index 89e01a885..8879a4173 100644
--- a/src/buildstream/_elementfactory.py
+++ b/src/buildstream/_pluginfactory/elementfactory.py
@@ -17,9 +17,10 @@
# Authors:
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
-from . import _site
-from ._plugincontext import PluginContext
-from .element import Element
+from .. import _site
+from ..element import Element
+
+from .pluginfactory import PluginFactory
# A ElementFactory creates Element instances
@@ -27,18 +28,12 @@ from .element import Element
#
# Args:
# plugin_base (PluginBase): The main PluginBase object to work with
-# plugin_origins (list): Data used to search for external Element plugins
#
-class ElementFactory(PluginContext):
- def __init__(self, plugin_base, *, format_versions={}, plugin_origins=None):
+class ElementFactory(PluginFactory):
+ def __init__(self, plugin_base):
super().__init__(
- plugin_base,
- Element,
- [_site.element_plugins],
- "buildstream.plugins.elements",
- plugin_origins=plugin_origins,
- format_versions=format_versions,
+ plugin_base, Element, [_site.element_plugins], "buildstream.plugins.elements",
)
# create():
@@ -60,6 +55,4 @@ class ElementFactory(PluginContext):
def create(self, context, project, meta):
element_type, default_config = self.lookup(meta.kind)
element = element_type(context, project, meta, default_config)
- version = self._format_versions.get(meta.kind, 0)
- self._assert_plugin_format(element, version)
return element
diff --git a/src/buildstream/_plugincontext.py b/src/buildstream/_pluginfactory/pluginfactory.py
index 3a195e239..c42b0a3d2 100644
--- a/src/buildstream/_plugincontext.py
+++ b/src/buildstream/_pluginfactory/pluginfactory.py
@@ -20,9 +20,9 @@
import os
import inspect
-from ._exceptions import PluginError, LoadError
-from .exceptions import LoadErrorReason
-from . import utils
+from .._exceptions import PluginError
+
+from .pluginorigin import PluginOrigin, PluginOriginType
# A Context for loading plugin types
@@ -32,9 +32,6 @@ from . import utils
# base_type (type): A base object type for this context
# site_plugin_path (str): Path to where buildstream keeps plugins
# entrypoint_group (str): Name of the entry point group that provides plugins
-# plugin_origins (list): Data used to search for plugins
-# format_versions (dict): A dict of meta.kind to the integer minimum
-# version number for each plugin to be loaded
#
# Since multiple pipelines can be processed recursively
# within the same interpretor, it's important that we have
@@ -43,16 +40,8 @@ from . import utils
# a given BuildStream project are isolated to their respective
# Pipelines.
#
-class PluginContext:
- def __init__(
- self, plugin_base, base_type, site_plugin_path, entrypoint_group, *, plugin_origins=None, format_versions={}
- ):
-
- # For pickling across processes, make sure this context has a unique
- # identifier, which we prepend to the identifier of each PluginSource.
- # This keeps plugins loaded during the first and second pass distinct
- # from eachother.
- self._identifier = str(id(self))
+class PluginFactory:
+ def __init__(self, plugin_base, base_type, site_plugin_path, entrypoint_group):
# The plugin kinds which were loaded
self.loaded_dependencies = []
@@ -60,16 +49,22 @@ class PluginContext:
#
# Private members
#
+
+ # For pickling across processes, make sure this context has a unique
+ # identifier, which we prepend to the identifier of each PluginSource.
+ # This keeps plugins loaded during the first and second pass distinct
+ # from eachother.
+ self._identifier = str(id(self))
+
self._base_type = base_type # The base class plugins derive from
self._types = {} # Plugin type lookup table by kind
- self._plugin_origins = plugin_origins or []
+ self._origins = {} # PluginOrigin lookup table by kind
# The PluginSource object
self._plugin_base = plugin_base
self._site_plugin_path = site_plugin_path
self._entrypoint_group = entrypoint_group
self._alternate_sources = {}
- self._format_versions = format_versions
self._init_site_source()
@@ -127,6 +122,23 @@ class PluginContext:
def lookup(self, kind):
return self._ensure_plugin(kind)
+ # register_plugin_origin():
+ #
+ # Registers the PluginOrigin to use for the given plugin kind
+ #
+ # Args:
+ # kind (str): The kind identifier of the Plugin
+ # origin (PluginOrigin): The PluginOrigin providing the plugin
+ #
+ def register_plugin_origin(self, kind: str, origin: PluginOrigin):
+ if kind in self._origins:
+ raise PluginError(
+ "More than one {} plugin registered as kind '{}'".format(self._base_type.__name__, kind),
+ reason="duplicate-plugin",
+ )
+
+ self._origins[kind] = origin
+
# all_loaded_plugins():
#
# Returns: an iterable over all the loaded plugins.
@@ -186,39 +198,27 @@ class PluginContext:
def _ensure_plugin(self, kind):
if kind not in self._types:
- # Check whether the plugin is specified in plugins
source = None
defaults = None
- loaded_dependency = False
-
- for origin in self._plugin_origins:
- if kind not in origin.get_str_list("plugins"):
- continue
-
- if origin.get_str("origin") == "local":
- local_path = origin.get_str("path")
- source = self._get_local_plugin_source(local_path)
- elif origin.get_str("origin") == "pip":
- package_name = origin.get_str("package-name")
- source, defaults = self._get_pip_plugin_source(package_name, kind)
- else:
- raise PluginError(
- "Failed to load plugin '{}': "
- "Unexpected plugin origin '{}'".format(kind, origin.get_str("origin"))
- )
- loaded_dependency = True
- break
- # Fall back to getting the source from site
- if not source:
+ origin = self._origins.get(kind, None)
+ if origin:
+ # Try getting the plugin source from a registered origin
+ if origin.origin_type == PluginOriginType.LOCAL:
+ source = self._get_local_plugin_source(origin.path)
+ elif origin.origin_type == PluginOriginType.PIP:
+ source, defaults = self._get_pip_plugin_source(origin.package_name, kind)
+ else:
+ assert False, "Encountered invalid plugin origin type"
+ else:
+ # Try getting it from the core plugins
if kind not in self._site_source.list_plugins():
raise PluginError("No {} type registered for kind '{}'".format(self._base_type.__name__, kind))
source = self._site_source
self._types[kind] = self._load_plugin(source, kind, defaults)
- if loaded_dependency:
- self.loaded_dependencies.append(kind)
+ self.loaded_dependencies.append(kind)
return self._types[kind]
@@ -248,7 +248,6 @@ class PluginContext:
) from e
self._assert_plugin(kind, plugin_type)
- self._assert_version(kind, plugin_type)
return (plugin_type, defaults)
def _assert_plugin(self, kind, plugin_type):
@@ -270,37 +269,3 @@ class PluginContext:
self._base_type.__name__, kind, self._base_type.__name__
)
) from e
-
- def _assert_version(self, kind, plugin_type):
-
- # Now assert BuildStream version
- bst_major, bst_minor = utils.get_bst_version()
-
- req_major = plugin_type.BST_REQUIRED_VERSION_MAJOR
- req_minor = plugin_type.BST_REQUIRED_VERSION_MINOR
-
- if (bst_major, bst_minor) < (req_major, req_minor):
- raise PluginError(
- "BuildStream {}.{} is too old for {} plugin '{}' (requires {}.{})".format(
- bst_major,
- bst_minor,
- self._base_type.__name__,
- kind,
- plugin_type.BST_REQUIRED_VERSION_MAJOR,
- plugin_type.BST_REQUIRED_VERSION_MINOR,
- )
- )
-
- # _assert_plugin_format()
- #
- # Helper to raise a PluginError if the loaded plugin is of a lesser version then
- # the required version for this plugin
- #
- def _assert_plugin_format(self, plugin, version):
- if plugin.BST_FORMAT_VERSION < version:
- raise LoadError(
- "{}: Format version {} is too old for requested version {}".format(
- plugin, plugin.BST_FORMAT_VERSION, version
- ),
- LoadErrorReason.UNSUPPORTED_PLUGIN,
- )
diff --git a/src/buildstream/_pluginfactory/pluginorigin.py b/src/buildstream/_pluginfactory/pluginorigin.py
new file mode 100644
index 000000000..50852711b
--- /dev/null
+++ b/src/buildstream/_pluginfactory/pluginorigin.py
@@ -0,0 +1,130 @@
+#
+# Copyright (C) 2020 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+
+from ..types import FastEnum
+
+
+# PluginOriginType:
+#
+# An enumeration depicting the type of plugin origin
+#
+class PluginOriginType(FastEnum):
+ LOCAL = "local"
+ PIP = "pip"
+
+
+# PluginOrigin
+#
+# Base class holding common properties of all origins.
+#
+class PluginOrigin:
+
+ # Common fields valid for all plugin origins
+ _COMMON_CONFIG_KEYS = ["origin", "sources", "elements"]
+
+ def __init__(self, origin_type):
+
+ # Public
+ self.origin_type = origin_type
+ self.elements = []
+ self.sources = []
+
+ # Private
+ self._project = None
+ self._kinds = {}
+
+ # new_from_node()
+ #
+ # Load a PluginOrigin from the YAML in project.conf
+ #
+ # Args:
+ # project (Project): The project from whence this origin is loaded
+ # origin_node (MappingNode): The node defining this origin
+ #
+ # Returns:
+ # (PluginOrigin): The newly created PluginOrigin
+ #
+ @classmethod
+ def new_from_node(cls, project, origin_node):
+
+ origin_type = origin_node.get_enum("origin", PluginOriginType)
+
+ if origin_type == PluginOriginType.LOCAL:
+ origin = PluginOriginLocal()
+ elif origin_type == PluginOriginType.PIP:
+ origin = PluginOriginPip()
+
+ origin._project = project
+ origin._load(origin_node)
+
+ origin.elements = origin_node.get_str_list("elements", [])
+ origin.sources = origin_node.get_str_list("sources", [])
+
+ return origin
+
+ # _load()
+ #
+ # Abstract method for loading data from the origin node, this
+ # method should not load the source and element lists.
+ #
+ # Args:
+ # origin_node (MappingNode): The node defining this origin
+ #
+ def _load(self, origin_node):
+ pass
+
+
+# PluginOriginLocal
+#
+# PluginOrigin for local plugins
+#
+class PluginOriginLocal(PluginOrigin):
+ def __init__(self):
+ super().__init__(PluginOriginType.LOCAL)
+
+ # An absolute path to where the plugin can be found
+ #
+ self.path = None
+
+ def _load(self, origin_node):
+
+ origin_node.validate_keys(["path", *PluginOrigin._COMMON_CONFIG_KEYS])
+
+ path_node = origin_node.get_scalar("path")
+ path = self._project.get_path_from_node(path_node, check_is_dir=True)
+
+ self.path = os.path.join(self._project.directory, path)
+
+
+# PluginOriginPip
+#
+# PluginOrigin for pip plugins
+#
+class PluginOriginPip(PluginOrigin):
+ def __init__(self):
+ super().__init__(PluginOriginType.PIP)
+
+ # The pip package name to extract plugins from
+ #
+ self.package_name = None
+
+ def _load(self, origin_node):
+
+ origin_node.validate_keys(["package-name", *PluginOrigin._COMMON_CONFIG_KEYS])
+ self.package_name = origin_node.get_str("package-name")
diff --git a/src/buildstream/_sourcefactory.py b/src/buildstream/_pluginfactory/sourcefactory.py
index 254c482d6..9f6a09784 100644
--- a/src/buildstream/_sourcefactory.py
+++ b/src/buildstream/_pluginfactory/sourcefactory.py
@@ -17,9 +17,10 @@
# Authors:
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
-from . import _site
-from ._plugincontext import PluginContext
-from .source import Source
+from .. import _site
+from ..source import Source
+
+from .pluginfactory import PluginFactory
# A SourceFactory creates Source instances
@@ -27,18 +28,12 @@ from .source import Source
#
# Args:
# plugin_base (PluginBase): The main PluginBase object to work with
-# plugin_origins (list): Data used to search for external Source plugins
#
-class SourceFactory(PluginContext):
- def __init__(self, plugin_base, *, format_versions={}, plugin_origins=None):
+class SourceFactory(PluginFactory):
+ def __init__(self, plugin_base):
super().__init__(
- plugin_base,
- Source,
- [_site.source_plugins],
- "buildstream.plugins.sources",
- format_versions=format_versions,
- plugin_origins=plugin_origins,
+ plugin_base, Source, [_site.source_plugins], "buildstream.plugins.sources",
)
# create():
@@ -61,6 +56,4 @@ class SourceFactory(PluginContext):
def create(self, context, project, meta):
source_type, _ = self.lookup(meta.kind)
source = source_type(context, project, meta)
- version = self._format_versions.get(meta.kind, 0)
- self._assert_plugin_format(source, version)
return source
diff --git a/src/buildstream/_project.py b/src/buildstream/_project.py
index 3527d211f..40524d7ad 100644
--- a/src/buildstream/_project.py
+++ b/src/buildstream/_project.py
@@ -36,13 +36,11 @@ from ._artifactcache import ArtifactCache
from ._sourcecache import SourceCache
from .node import ScalarNode, SequenceNode, _assert_symbol_name
from .sandbox import SandboxRemote
-from ._elementfactory import ElementFactory
-from ._sourcefactory import SourceFactory
+from ._pluginfactory import ElementFactory, SourceFactory, PluginOrigin
from .types import CoreWarnings
from ._projectrefs import ProjectRefs, ProjectRefStorage
from ._loader import Loader
from .element import Element
-from .types import FastEnum
from ._message import Message, MessageType
from ._includes import Includes
from ._workspaces import WORKSPACE_PROJECT_FILE
@@ -52,13 +50,6 @@ from ._workspaces import WORKSPACE_PROJECT_FILE
_PROJECT_CONF_FILE = "project.conf"
-# List of all places plugins can come from
-class PluginOrigins(FastEnum):
- CORE = "core"
- LOCAL = "local"
- PIP = "pip"
-
-
# HostMount()
#
# A simple object describing the behavior of
@@ -951,87 +942,19 @@ class Project:
return project_directory, workspace_element
def _load_plugin_factories(self, config, output):
- plugin_source_origins = [] # Origins of custom sources
- plugin_element_origins = [] # Origins of custom elements
-
- # Plugin origins and versions
- origins = config.get_sequence("plugins", default=[])
- source_format_versions = {}
- element_format_versions = {}
- for origin in origins:
- allowed_origin_fields = [
- "origin",
- "sources",
- "elements",
- "package-name",
- "path",
- ]
- origin.validate_keys(allowed_origin_fields)
-
- # Store source versions for checking later
- source_versions = origin.get_mapping("sources", default={})
- for key in source_versions.keys():
- if key in source_format_versions:
- raise LoadError("Duplicate listing of source '{}'".format(key), LoadErrorReason.INVALID_YAML)
- source_format_versions[key] = source_versions.get_int(key)
-
- # Store element versions for checking later
- element_versions = origin.get_mapping("elements", default={})
- for key in element_versions.keys():
- if key in element_format_versions:
- raise LoadError("Duplicate listing of element '{}'".format(key), LoadErrorReason.INVALID_YAML)
- element_format_versions[key] = element_versions.get_int(key)
-
- # Store the origins if they're not 'core'.
- # core elements are loaded by default, so storing is unnecessary.
- origin_value = origin.get_enum("origin", PluginOrigins)
-
- if origin_value != PluginOrigins.CORE:
- self._store_origin(origin, "sources", plugin_source_origins)
- self._store_origin(origin, "elements", plugin_element_origins)
-
+ # Create the factories
pluginbase = PluginBase(package="buildstream.plugins")
- output.element_factory = ElementFactory(
- pluginbase, plugin_origins=plugin_element_origins, format_versions=element_format_versions
- )
- output.source_factory = SourceFactory(
- pluginbase, plugin_origins=plugin_source_origins, format_versions=source_format_versions
- )
+ output.element_factory = ElementFactory(pluginbase)
+ output.source_factory = SourceFactory(pluginbase)
- # _store_origin()
- #
- # Helper function to store plugin origins
- #
- # Args:
- # origin (node) - a node indicating the origin of a group of
- # plugins.
- # plugin_group (str) - The name of the type of plugin that is being
- # loaded
- # destination (list) - A list of nodes to store the origins in
- #
- # Raises:
- # LoadError if 'origin' is an unexpected value
- def _store_origin(self, origin, plugin_group, destination):
- expected_groups = ["sources", "elements"]
- if plugin_group not in expected_groups:
- raise LoadError(
- "Unexpected plugin group: {}, expecting {}".format(plugin_group, expected_groups),
- LoadErrorReason.INVALID_DATA,
- )
- if plugin_group in origin.keys():
- origin_node = origin.clone()
- plugins = origin.get_mapping(plugin_group, default={})
- origin_node["plugins"] = plugins.keys()
-
- for group in expected_groups:
- if group in origin_node:
- del origin_node[group]
-
- if origin_node.get_enum("origin", PluginOrigins) == PluginOrigins.LOCAL:
- path = self.get_path_from_node(origin.get_scalar("path"), check_is_dir=True)
- # paths are passed in relative to the project, but must be absolute
- origin_node["path"] = os.path.join(self.directory, path)
- destination.append(origin_node)
+ # Load the plugin origins and register them to their factories
+ origins = config.get_sequence("plugins", default=[])
+ for origin_node in origins:
+ origin = PluginOrigin.new_from_node(self, origin_node)
+ for kind in origin.elements:
+ output.element_factory.register_plugin_origin(kind, origin)
+ for kind in origin.sources:
+ output.source_factory.register_plugin_origin(kind, origin)
# _warning_is_fatal():
#
diff --git a/src/buildstream/plugin.py b/src/buildstream/plugin.py
index 2182f5a08..4f2d74304 100644
--- a/src/buildstream/plugin.py
+++ b/src/buildstream/plugin.py
@@ -148,27 +148,6 @@ class Plugin:
which are included in the buildstream namespace.
"""
- BST_REQUIRED_VERSION_MAJOR = 0
- """Minimum required major version"""
-
- BST_REQUIRED_VERSION_MINOR = 0
- """Minimum required minor version"""
-
- BST_FORMAT_VERSION = 0
- """The plugin's YAML format version
-
- This should be set to ``1`` the first time any new configuration
- is understood by your :func:`Plugin.configure() <buildstream.plugin.Plugin.configure>`
- implementation and subsequently bumped every time your
- configuration is enhanced.
-
- .. note::
-
- Plugins are expected to maintain backward compatibility
- in the format and configurations they expose. The versioning
- is intended to track availability of new features only.
- """
-
BST_PLUGIN_DEPRECATED = False
"""True if this element plugin has been deprecated.
diff --git a/src/buildstream/testing/_sourcetests/utils.py b/src/buildstream/testing/_sourcetests/utils.py
index 116506807..4cfb696bd 100644
--- a/src/buildstream/testing/_sourcetests/utils.py
+++ b/src/buildstream/testing/_sourcetests/utils.py
@@ -71,7 +71,7 @@ def add_plugins_conf(project, plugin_kind):
if plugin_package is not None:
project_conf["plugins"] = [
- {"origin": "pip", "package-name": plugin_package, "sources": {plugin_kind: 0,},},
+ {"origin": "pip", "package-name": plugin_package, "sources": [plugin_kind],},
]
_yaml.roundtrip_dump(project_conf, project_conf_file)
diff --git a/tests/elements/filter/basic/project.conf b/tests/elements/filter/basic/project.conf
index e0b487d01..023943f79 100644
--- a/tests/elements/filter/basic/project.conf
+++ b/tests/elements/filter/basic/project.conf
@@ -5,4 +5,4 @@ plugins:
- origin: local
path: element_plugins
elements:
- dynamic: 0
+ - dynamic
diff --git a/tests/format/project.py b/tests/format/project.py
index c2e2f733f..c4b2a480a 100644
--- a/tests/format/project.py
+++ b/tests/format/project.py
@@ -177,7 +177,7 @@ def test_plugin_no_load_ref(cli, datafiles, ref_storage):
"name": "test",
"min-version": "2.0",
"ref-storage": ref_storage,
- "plugins": [{"origin": "local", "path": "plugins", "sources": {"noloadref": 0}}],
+ "plugins": [{"origin": "local", "path": "plugins", "sources": ["noloadref"]}],
}
_yaml.roundtrip_dump(config, os.path.join(project, "project.conf"))
@@ -202,7 +202,7 @@ def test_plugin_preflight_error(cli, datafiles):
def test_duplicate_plugins(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename, "duplicate-plugins")
result = cli.run(project=project, silent=True, args=["show", "element.bst"])
- result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_YAML)
+ result.assert_main_error(ErrorDomain.PLUGIN, "duplicate-plugin")
# Assert that we get a different cache key for target.bst, depending
diff --git a/tests/format/project/duplicate-plugins/project.conf b/tests/format/project/duplicate-plugins/project.conf
index a413e6137..495ba0678 100644
--- a/tests/format/project/duplicate-plugins/project.conf
+++ b/tests/format/project/duplicate-plugins/project.conf
@@ -5,12 +5,12 @@ plugins:
- origin: local
path: bar
elements:
- foo: 0
+ - foo
sources:
- frob: 0
+ - frob
- origin: local
path: baz
elements:
- foo: 0
+ - foo
sources:
- frob: 0
+ - frob
diff --git a/tests/format/project/local-plugin/project.conf b/tests/format/project/local-plugin/project.conf
index ccb6ef433..7d8cc1aea 100644
--- a/tests/format/project/local-plugin/project.conf
+++ b/tests/format/project/local-plugin/project.conf
@@ -4,4 +4,4 @@ plugins:
- origin: local
path: plugins
sources:
- mysource: 0
+ - mysource
diff --git a/tests/format/project/plugin-allowed/project.conf b/tests/format/project/plugin-allowed/project.conf
index 3896b7bc2..97107edf6 100644
--- a/tests/format/project/plugin-allowed/project.conf
+++ b/tests/format/project/plugin-allowed/project.conf
@@ -5,4 +5,4 @@ plugins:
- origin: local
path: plugins
elements:
- foo: 0
+ - foo
diff --git a/tests/format/project/plugin-preflight-error/project.conf b/tests/format/project/plugin-preflight-error/project.conf
index 07d60daf2..ed1ddb99f 100644
--- a/tests/format/project/plugin-preflight-error/project.conf
+++ b/tests/format/project/plugin-preflight-error/project.conf
@@ -9,4 +9,4 @@ plugins:
- origin: local
path: errorplugin
sources:
- preflighterror: 0
+ - preflighterror
diff --git a/tests/frontend/configurable_warnings.py b/tests/frontend/configurable_warnings.py
index e61db6c37..53409a512 100644
--- a/tests/frontend/configurable_warnings.py
+++ b/tests/frontend/configurable_warnings.py
@@ -18,9 +18,7 @@ def get_project(fatal_warnings):
"name": "test",
"min-version": "2.0",
"element-path": "elements",
- "plugins": [
- {"origin": "local", "path": "plugins", "elements": {"warninga": 0, "warningb": 0, "corewarn": 0,}}
- ],
+ "plugins": [{"origin": "local", "path": "plugins", "elements": ["warninga", "warningb", "corewarn"]}],
"fatal-warnings": fatal_warnings,
}
diff --git a/tests/frontend/configuredwarning/project.conf b/tests/frontend/configuredwarning/project.conf
index 195ee176a..9d75ad18b 100644
--- a/tests/frontend/configuredwarning/project.conf
+++ b/tests/frontend/configuredwarning/project.conf
@@ -5,5 +5,5 @@ plugins:
- origin: local
path: element_plugins
elements:
- warninga: 0
- warningb: 0
+ - warninga
+ - warningb
diff --git a/tests/frontend/consistencyerror/project.conf b/tests/frontend/consistencyerror/project.conf
index d28ba12df..f5c1b39c5 100644
--- a/tests/frontend/consistencyerror/project.conf
+++ b/tests/frontend/consistencyerror/project.conf
@@ -9,5 +9,5 @@ plugins:
- origin: local
path: plugins
sources:
- consistencyerror: 0
- consistencybug: 0
+ - consistencyerror
+ - consistencybug
diff --git a/tests/frontend/mirror.py b/tests/frontend/mirror.py
index 848047ee8..bffc754e7 100644
--- a/tests/frontend/mirror.py
+++ b/tests/frontend/mirror.py
@@ -49,7 +49,7 @@ def generate_project():
{"name": "arrakis", "aliases": {"foo": ["OFO/"], "bar": ["RBA/"],},},
{"name": "oz", "aliases": {"foo": ["ooF/"], "bar": ["raB/"],}},
],
- "plugins": [{"origin": "local", "path": "sources", "sources": {"fetch_source": 0}}],
+ "plugins": [{"origin": "local", "path": "sources", "sources": ["fetch_source"]}],
}
return project
diff --git a/tests/frontend/push.py b/tests/frontend/push.py
index 362084372..970885784 100644
--- a/tests/frontend/push.py
+++ b/tests/frontend/push.py
@@ -641,7 +641,7 @@ def test_push_after_rebuild(cli, tmpdir, datafiles):
config={
"element-path": "elements",
"min-version": "2.0",
- "plugins": [{"origin": "local", "path": "plugins", "elements": {"randomelement": 0}}],
+ "plugins": [{"origin": "local", "path": "plugins", "elements": ["randomelement"]}],
},
)
diff --git a/tests/internals/pluginfactory.py b/tests/internals/pluginfactory.py
deleted file mode 100644
index 13b9d3aae..000000000
--- a/tests/internals/pluginfactory.py
+++ /dev/null
@@ -1,287 +0,0 @@
-# Pylint doesn't play well with fixtures and dependency injection from pytest
-# pylint: disable=redefined-outer-name
-
-import os
-import pytest
-
-from pluginbase import PluginBase
-from buildstream import Node
-from buildstream._elementfactory import ElementFactory
-from buildstream._sourcefactory import SourceFactory
-from buildstream._exceptions import PluginError
-
-DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "pluginfactory",)
-
-
-# Simple fixture to create a PluginBase object that
-# we use for loading plugins.
-@pytest.fixture()
-def plugin_fixture():
- return {"base": PluginBase(package="buildstream.plugins")}
-
-
-##############################################################
-# Basics: test the fixture, test we can create the factories #
-##############################################################
-def test_fixture(plugin_fixture):
- assert isinstance(plugin_fixture["base"], PluginBase)
-
-
-def test_source_factory(plugin_fixture):
- factory = SourceFactory(plugin_fixture["base"])
- assert isinstance(factory, SourceFactory)
-
-
-def test_element_factory(plugin_fixture):
- factory = ElementFactory(plugin_fixture["base"])
- assert isinstance(factory, ElementFactory)
-
-
-##############################################################
-# Check that we can load custom sources & elements #
-##############################################################
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "customsource"))
-def test_custom_source(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = SourceFactory(plugin_fixture["base"], plugin_origins=plugins)
- assert isinstance(factory, SourceFactory)
-
- foo_type, _ = factory.lookup("foo")
- assert foo_type.__name__ == "FooSource"
-
-
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "customelement"))
-def test_custom_element(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = ElementFactory(plugin_fixture["base"], plugin_origins=plugins)
- assert isinstance(factory, ElementFactory)
-
- foo_type, _ = factory.lookup("foo")
- assert foo_type.__name__ == "FooElement"
-
-
-##############################################################
-# Check plugin loading failure modes #
-##############################################################
-def test_missing_source(plugin_fixture):
- factory = SourceFactory(plugin_fixture["base"])
- assert isinstance(factory, SourceFactory)
-
- # Test fails if PluginError is not raised
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-def test_missing_element(plugin_fixture):
- factory = ElementFactory(plugin_fixture["base"])
- assert isinstance(factory, ElementFactory)
-
- # Test fails if PluginError is not raised
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin that returns a value instead of Source subclass
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "notatype"))
-def test_source_notatype(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = SourceFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin that returns a value instead of Element subclass
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "notatype"))
-def test_element_notatype(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = ElementFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin that returns a type
-# which is not a Source subclass
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "wrongtype"))
-def test_source_wrongtype(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = SourceFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin that returns a type
-# which is not a Element subclass
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "wrongtype"))
-def test_element_wrongtype(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = ElementFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin which fails to provide a setup() function
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "nosetup"))
-def test_source_missing_setup(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = SourceFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin which fails to provide a setup() function
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "nosetup"))
-def test_element_missing_setup(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = ElementFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin which provides a setup symbol
-# that is not a function
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "badsetup"))
-def test_source_bad_setup(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = SourceFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin which provides a setup symbol
-# that is not a function
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "badsetup"))
-def test_element_bad_setup(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = ElementFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin which requires an absurdly
-# high version of buildstream
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "badversionsource"))
-def test_source_badversion(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = SourceFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-# Load a factory with a plugin which requires an absurdly
-# high version of buildstream
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "badversionelement"))
-def test_element_badversion(plugin_fixture, datafiles):
- plugins = [
- Node.from_dict(
- {"origin": "local", "path": os.path.join(datafiles.dirname, datafiles.basename), "plugins": ["foo"]}
- )
- ]
- factory = ElementFactory(plugin_fixture["base"], plugin_origins=plugins)
- with pytest.raises(PluginError):
- factory.lookup("foo")
-
-
-##############################################################
-# Check we can load different contexts of plugin #
-##############################################################
-
-# Load two factories, both of which define a different 'foo' plugin
-@pytest.mark.datafiles(DATA_DIR)
-def test_source_multicontext(plugin_fixture, datafiles):
- plugins1 = Node.from_dict(
- {
- "origin": "local",
- "path": os.path.join(datafiles.dirname, datafiles.basename, "customsource"),
- "plugins": ["foo"],
- }
- )
- plugins2 = Node.from_dict(
- {
- "origin": "local",
- "path": os.path.join(datafiles.dirname, datafiles.basename, "anothersource"),
- "plugins": ["foo"],
- }
- )
-
- factory1 = SourceFactory(plugin_fixture["base"], plugin_origins=[plugins1])
- factory2 = SourceFactory(plugin_fixture["base"], plugin_origins=[plugins2])
- assert isinstance(factory1, SourceFactory)
- assert isinstance(factory2, SourceFactory)
-
- foo_type1, _ = factory1.lookup("foo")
- foo_type2, _ = factory2.lookup("foo")
- assert foo_type1.__name__ == "FooSource"
- assert foo_type2.__name__ == "AnotherFooSource"
-
-
-# Load two factories, both of which define a different 'foo' plugin
-@pytest.mark.datafiles(DATA_DIR)
-def test_element_multicontext(plugin_fixture, datafiles):
- plugins1 = Node.from_dict(
- {
- "origin": "local",
- "path": os.path.join(datafiles.dirname, datafiles.basename, "customelement"),
- "plugins": ["foo"],
- }
- )
- plugins2 = Node.from_dict(
- {
- "origin": "local",
- "path": os.path.join(datafiles.dirname, datafiles.basename, "anotherelement"),
- "plugins": ["foo"],
- }
- )
-
- factory1 = ElementFactory(plugin_fixture["base"], plugin_origins=[plugins1])
- factory2 = ElementFactory(plugin_fixture["base"], plugin_origins=[plugins2])
- assert isinstance(factory1, ElementFactory)
- assert isinstance(factory2, ElementFactory)
-
- foo_type1, _ = factory1.lookup("foo")
- foo_type2, _ = factory2.lookup("foo")
- assert foo_type1.__name__ == "FooElement"
- assert foo_type2.__name__ == "AnotherFooElement"
diff --git a/tests/internals/pluginfactory/anotherelement/__init__.py b/tests/internals/pluginfactory/anotherelement/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/anotherelement/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/anotherelement/foo.py b/tests/internals/pluginfactory/anotherelement/foo.py
deleted file mode 100644
index 2e067a94f..000000000
--- a/tests/internals/pluginfactory/anotherelement/foo.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from buildstream import Element
-
-
-class AnotherFooElement(Element):
- pass
-
-
-def setup():
- return AnotherFooElement
diff --git a/tests/internals/pluginfactory/anothersource/__init__.py b/tests/internals/pluginfactory/anothersource/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/anothersource/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/anothersource/foo.py b/tests/internals/pluginfactory/anothersource/foo.py
deleted file mode 100644
index 4675b965f..000000000
--- a/tests/internals/pluginfactory/anothersource/foo.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from buildstream import Source
-
-
-class AnotherFooSource(Source):
- pass
-
-
-def setup():
- return AnotherFooSource
diff --git a/tests/internals/pluginfactory/badsetup/__init__.py b/tests/internals/pluginfactory/badsetup/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/badsetup/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/badsetup/foo.py b/tests/internals/pluginfactory/badsetup/foo.py
deleted file mode 100644
index 145f2577b..000000000
--- a/tests/internals/pluginfactory/badsetup/foo.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# A plugin is supposed to define a setup function
-# which returns the type that the plugin provides
-#
-# This plugin provides a setup() symbol that is
-# not even a function
-setup = 5
diff --git a/tests/internals/pluginfactory/badversionelement/__init__.py b/tests/internals/pluginfactory/badversionelement/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/badversionelement/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/badversionelement/foo.py b/tests/internals/pluginfactory/badversionelement/foo.py
deleted file mode 100644
index 2a8b12abe..000000000
--- a/tests/internals/pluginfactory/badversionelement/foo.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from buildstream import Element
-
-
-class FooElement(Element):
-
- # We have a little while until we have to manually modify this
- BST_REQUIRED_VERSION_MAJOR = 5000
-
-
-def setup():
- return FooElement
diff --git a/tests/internals/pluginfactory/badversionsource/__init__.py b/tests/internals/pluginfactory/badversionsource/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/badversionsource/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/badversionsource/foo.py b/tests/internals/pluginfactory/badversionsource/foo.py
deleted file mode 100644
index 23333a9d8..000000000
--- a/tests/internals/pluginfactory/badversionsource/foo.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from buildstream import Source
-
-
-class FooSource(Source):
-
- # We have a little while until we have to manually modify this
- BST_REQUIRED_VERSION_MAJOR = 5000
-
-
-def setup():
- return FooSource
diff --git a/tests/internals/pluginfactory/customelement/__init__.py b/tests/internals/pluginfactory/customelement/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/customelement/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/customelement/foo.py b/tests/internals/pluginfactory/customelement/foo.py
deleted file mode 100644
index 260de8b27..000000000
--- a/tests/internals/pluginfactory/customelement/foo.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from buildstream import Element
-
-
-class FooElement(Element):
- pass
-
-
-def setup():
- return FooElement
diff --git a/tests/internals/pluginfactory/customsource/__init__.py b/tests/internals/pluginfactory/customsource/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/customsource/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/customsource/foo.py b/tests/internals/pluginfactory/customsource/foo.py
deleted file mode 100644
index de78a00ce..000000000
--- a/tests/internals/pluginfactory/customsource/foo.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from buildstream import Source
-
-
-class FooSource(Source):
- pass
-
-
-def setup():
- return FooSource
diff --git a/tests/internals/pluginfactory/nosetup/__init__.py b/tests/internals/pluginfactory/nosetup/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/nosetup/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/nosetup/foo.py b/tests/internals/pluginfactory/nosetup/foo.py
deleted file mode 100644
index 0b5a4fa7e..000000000
--- a/tests/internals/pluginfactory/nosetup/foo.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# A plugin is supposed to define a setup function
-# which returns the type that the plugin provides
-#
-# This plugin fails to do so
-
-
-def useless():
- print("Hello World")
diff --git a/tests/internals/pluginfactory/notatype/__init__.py b/tests/internals/pluginfactory/notatype/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/notatype/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/notatype/foo.py b/tests/internals/pluginfactory/notatype/foo.py
deleted file mode 100644
index 311a4fb32..000000000
--- a/tests/internals/pluginfactory/notatype/foo.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# Plugins are supposed to return a subclass type
-# of Source or Element, depending on plugin type.
-
-
-def setup():
- return 5
diff --git a/tests/internals/pluginfactory/wrongtype/__init__.py b/tests/internals/pluginfactory/wrongtype/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginfactory/wrongtype/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginfactory/wrongtype/foo.py b/tests/internals/pluginfactory/wrongtype/foo.py
deleted file mode 100644
index 37d9f6bfe..000000000
--- a/tests/internals/pluginfactory/wrongtype/foo.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Plugins are supposed to return a subclass type
-# of Source or Element, depending on plugin type.
-#
-# This one fails the requirement
-
-
-class Foo:
- pass
-
-
-def setup():
- return Foo
diff --git a/tests/internals/pluginloading.py b/tests/internals/pluginloading.py
index 0685b09da..1f4446541 100644
--- a/tests/internals/pluginloading.py
+++ b/tests/internals/pluginloading.py
@@ -3,8 +3,6 @@ import os
import pytest
from buildstream._project import Project
-from buildstream._exceptions import LoadError
-from buildstream.exceptions import LoadErrorReason
from buildstream._pipeline import Pipeline
from tests.testutils import dummy_context
@@ -38,23 +36,3 @@ def test_customelement(datafiles, tmpdir):
basedir = str(datafiles)
with create_pipeline(tmpdir, basedir, "simple.bst") as targets:
assert targets[0].get_kind() == "foo"
-
-
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "badversionsource"))
-def test_badversionsource(datafiles, tmpdir):
- basedir = str(datafiles)
-
- with pytest.raises(LoadError) as exc, create_pipeline(tmpdir, basedir, "simple.bst"):
- pass
-
- assert exc.value.reason == LoadErrorReason.UNSUPPORTED_PLUGIN
-
-
-@pytest.mark.datafiles(os.path.join(DATA_DIR, "badversionelement"))
-def test_badversionelement(datafiles, tmpdir):
- basedir = str(datafiles)
-
- with pytest.raises(LoadError) as exc, create_pipeline(tmpdir, basedir, "simple.bst"):
- pass
-
- assert exc.value.reason == LoadErrorReason.UNSUPPORTED_PLUGIN
diff --git a/tests/internals/pluginloading/badversionelement/customelements/__init__.py b/tests/internals/pluginloading/badversionelement/customelements/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginloading/badversionelement/customelements/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginloading/badversionelement/customelements/foo.py b/tests/internals/pluginloading/badversionelement/customelements/foo.py
deleted file mode 100644
index 75536e87f..000000000
--- a/tests/internals/pluginloading/badversionelement/customelements/foo.py
+++ /dev/null
@@ -1,19 +0,0 @@
-from buildstream import Element
-
-
-class FooElement(Element):
-
- BST_FORMAT_VERSION = 5
-
- def preflight(self):
- pass
-
- def configure(self, node):
- pass
-
- def get_unique_key(self):
- return {}
-
-
-def setup():
- return FooElement
diff --git a/tests/internals/pluginloading/badversionelement/elements/simple.bst b/tests/internals/pluginloading/badversionelement/elements/simple.bst
deleted file mode 100644
index f949dc5b5..000000000
--- a/tests/internals/pluginloading/badversionelement/elements/simple.bst
+++ /dev/null
@@ -1,4 +0,0 @@
-kind: foo
-description: Custom foo element
-config:
- some: thing
diff --git a/tests/internals/pluginloading/badversionelement/project.conf b/tests/internals/pluginloading/badversionelement/project.conf
deleted file mode 100644
index bff73e251..000000000
--- a/tests/internals/pluginloading/badversionelement/project.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-name: pony
-min-version: 2.0
-element-path: elements
-
-plugins:
-- origin: local
- path: customelements
- elements:
- # We provided bar at version 5, should be a conflict.
- foo: 10
diff --git a/tests/internals/pluginloading/badversionsource/customsources/__init__.py b/tests/internals/pluginloading/badversionsource/customsources/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/tests/internals/pluginloading/badversionsource/customsources/__init__.py
+++ /dev/null
diff --git a/tests/internals/pluginloading/badversionsource/customsources/foo.py b/tests/internals/pluginloading/badversionsource/customsources/foo.py
deleted file mode 100644
index 628f99b29..000000000
--- a/tests/internals/pluginloading/badversionsource/customsources/foo.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from buildstream import Source
-
-
-class BarSource(Source):
-
- BST_FORMAT_VERSION = 5
-
- def preflight(self):
- pass
-
- def configure(self, node):
- pass
-
-
-def setup():
- return BarSource
diff --git a/tests/internals/pluginloading/badversionsource/elements/simple.bst b/tests/internals/pluginloading/badversionsource/elements/simple.bst
deleted file mode 100644
index 7e0cc43b7..000000000
--- a/tests/internals/pluginloading/badversionsource/elements/simple.bst
+++ /dev/null
@@ -1,6 +0,0 @@
-kind: autotools
-description: Custom foo source
-sources:
-- kind: foo
- ref: 1.2.3
- uri: http://ponyland.com
diff --git a/tests/internals/pluginloading/badversionsource/project.conf b/tests/internals/pluginloading/badversionsource/project.conf
deleted file mode 100644
index cd5b2dc82..000000000
--- a/tests/internals/pluginloading/badversionsource/project.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-name: pony
-min-version: 2.0
-element-path: elements
-
-plugins:
-- origin: local
- path: customsources
- sources:
- # We provided bar at version 5, should be a conflict.
- foo: 10
diff --git a/tests/internals/pluginloading/customelement/project.conf b/tests/internals/pluginloading/customelement/project.conf
index 6a33cc504..2619bdf82 100644
--- a/tests/internals/pluginloading/customelement/project.conf
+++ b/tests/internals/pluginloading/customelement/project.conf
@@ -5,4 +5,4 @@ plugins:
- origin: local
path: pluginelements
elements:
- foo: 0
+ - foo
diff --git a/tests/internals/pluginloading/customsource/project.conf b/tests/internals/pluginloading/customsource/project.conf
index 87d9b5d09..5cb6da537 100644
--- a/tests/internals/pluginloading/customsource/project.conf
+++ b/tests/internals/pluginloading/customsource/project.conf
@@ -5,4 +5,4 @@ plugins:
- origin: local
path: pluginsources
sources:
- foo: 0
+ - foo
diff --git a/tests/plugins/deprecationwarnings/project/project.conf b/tests/plugins/deprecationwarnings/project/project.conf
index 8a2536cab..9e03afe0a 100644
--- a/tests/plugins/deprecationwarnings/project/project.conf
+++ b/tests/plugins/deprecationwarnings/project/project.conf
@@ -12,4 +12,4 @@ plugins:
- origin: local
path: plugins/elements
elements:
- deprecated_plugin: 0
+ - deprecated_plugin
diff --git a/tests/sourcecache/project/project.conf b/tests/sourcecache/project/project.conf
index dde417f71..e3635e8a7 100644
--- a/tests/sourcecache/project/project.conf
+++ b/tests/sourcecache/project/project.conf
@@ -9,4 +9,4 @@ plugins:
- origin: local
path: plugins/elements
elements:
- always_fail: 0 \ No newline at end of file
+ - always_fail
diff --git a/tests/sources/no-fetch-cached/project.conf b/tests/sources/no-fetch-cached/project.conf
index eeb00d432..ef5b4a3b9 100644
--- a/tests/sources/no-fetch-cached/project.conf
+++ b/tests/sources/no-fetch-cached/project.conf
@@ -6,4 +6,4 @@ plugins:
- origin: local
path: plugins/sources
sources:
- always_cached: 0
+ - always_cached
diff --git a/tests/sources/previous_source_access/project.conf b/tests/sources/previous_source_access/project.conf
index 2d3bb1fb2..b08df35f0 100644
--- a/tests/sources/previous_source_access/project.conf
+++ b/tests/sources/previous_source_access/project.conf
@@ -11,4 +11,4 @@ plugins:
- origin: local
path: plugins/sources
sources:
- foo_transform: 0
+ - foo_transform
diff --git a/tests/sources/project_key_test/project.conf b/tests/sources/project_key_test/project.conf
index fb9ba1f88..6b82d4055 100644
--- a/tests/sources/project_key_test/project.conf
+++ b/tests/sources/project_key_test/project.conf
@@ -8,4 +8,4 @@ plugins:
- origin: local
path: plugins/sources
sources:
- key-test: 0 \ No newline at end of file
+ - key-test