diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-04-27 17:12:08 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-04-29 16:24:59 +0900 |
commit | b3556a3284708b904f20586d4636c31a91106809 (patch) | |
tree | af74bdc3f02ba14150b060c6e7cf617d663aec7d /src/buildstream/_pluginfactory | |
parent | 3b1af6036c14d4a9b017776358b4ac4c5622ec9e (diff) | |
download | buildstream-b3556a3284708b904f20586d4636c31a91106809.tar.gz |
tests/plugins/loading.py: New test replaces removed internal test
This test tests some of the basic failure modes of plugin loading,
which used to be written as internal tests but is not implemented
as a proper end-to-end test.
This commit also adds some machine readable reason codes to
pluginfactory.py so that we can assert the errors more specifically.
Diffstat (limited to 'src/buildstream/_pluginfactory')
-rw-r--r-- | src/buildstream/_pluginfactory/pluginfactory.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/buildstream/_pluginfactory/pluginfactory.py b/src/buildstream/_pluginfactory/pluginfactory.py index c42b0a3d2..7e5ae2db0 100644 --- a/src/buildstream/_pluginfactory/pluginfactory.py +++ b/src/buildstream/_pluginfactory/pluginfactory.py @@ -240,11 +240,13 @@ class PluginFactory: plugin_type = plugin.setup() except AttributeError as e: raise PluginError( - "{} plugin '{}' did not provide a setup() function".format(self._base_type.__name__, kind) + "{} plugin '{}' did not provide a setup() function".format(self._base_type.__name__, kind), + reason="missing-setup-function", ) from e except TypeError as e: raise PluginError( - "setup symbol in {} plugin '{}' is not a function".format(self._base_type.__name__, kind) + "setup symbol in {} plugin '{}' is not a function".format(self._base_type.__name__, kind), + reason="setup-is-not-function", ) from e self._assert_plugin(kind, plugin_type) @@ -261,11 +263,13 @@ class PluginFactory: raise PluginError( "{} plugin '{}' returned type '{}', which is not a subclass of {}".format( self._base_type.__name__, kind, plugin_type.__name__, self._base_type.__name__ - ) + ), + reason="setup-returns-bad-type", ) except TypeError as e: raise PluginError( "{} plugin '{}' returned something that is not a type (expected subclass of {})".format( self._base_type.__name__, kind, self._base_type.__name__ - ) + ), + reason="setup-returns-not-type", ) from e |