diff options
author | Phil Dawson <phil.dawson@codethink.co.uk> | 2019-01-10 10:00:27 +0000 |
---|---|---|
committer | Phil Dawson <phil.dawson@codethink.co.uk> | 2019-02-20 11:10:31 +0000 |
commit | 59ce7bfba6afa2294e120eb97338c284d7156646 (patch) | |
tree | a836f2253300c83a2ce9aab486fa928277a7bd1f /tests | |
parent | cf01c3bf36994eb1577d079ca853cd59699bfa99 (diff) | |
download | buildstream-59ce7bfba6afa2294e120eb97338c284d7156646.tar.gz |
plugin.py: Add API to allow plugins to raise deprecation warningsphil/848-plugin-deprecation-warnings
A plugin's deprecation warning may be silenced by a project by adding
the plugin to the list 'supress-deprecation-warnings' in the project's
project.conf
Diffstat (limited to 'tests')
5 files changed, 90 insertions, 0 deletions
diff --git a/tests/plugins/deprecationwarnings/deprecationwarnings.py b/tests/plugins/deprecationwarnings/deprecationwarnings.py new file mode 100644 index 000000000..799f162dc --- /dev/null +++ b/tests/plugins/deprecationwarnings/deprecationwarnings.py @@ -0,0 +1,41 @@ +import pytest +import tempfile +import os +from buildstream.plugintestutils import cli +from buildstream import _yaml +import buildstream.plugins.elements.manual + + +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "project" +) + +_DEPRECATION_MESSAGE = "Here is some detail." +_DEPRECATION_WARNING = "Using deprecated plugin deprecated_plugin: {}".format(_DEPRECATION_MESSAGE) + + +@pytest.mark.datafiles(DATA_DIR) +def test_deprecation_warning_present(cli, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + result = cli.run(project=project, args=['show', 'deprecated.bst']) + result.assert_success() + assert _DEPRECATION_WARNING in result.stderr + + +@pytest.mark.datafiles(DATA_DIR) +def test_suppress_deprecation_warning(cli, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename) + result = cli.run(project=project, args=['show', 'manual.bst']) + + element_overrides = "elements:\n" \ + " deprecated_plugin:\n" \ + " suppress-deprecation-warnings : True\n" + + project_conf = os.path.join(project, 'project.conf') + with open(project_conf, 'a') as f: + f.write(element_overrides) + + result = cli.run(project=project, args=['show', 'deprecated.bst']) + result.assert_success() + assert _DEPRECATION_WARNING not in result.stderr diff --git a/tests/plugins/deprecationwarnings/project/elements/deprecated.bst b/tests/plugins/deprecationwarnings/project/elements/deprecated.bst new file mode 100644 index 000000000..e80bd91cd --- /dev/null +++ b/tests/plugins/deprecationwarnings/project/elements/deprecated.bst @@ -0,0 +1 @@ +kind: deprecated_plugin
\ No newline at end of file diff --git a/tests/plugins/deprecationwarnings/project/plugins/elements/deprecated_plugin.py b/tests/plugins/deprecationwarnings/project/plugins/elements/deprecated_plugin.py new file mode 100644 index 000000000..a8e39562a --- /dev/null +++ b/tests/plugins/deprecationwarnings/project/plugins/elements/deprecated_plugin.py @@ -0,0 +1,11 @@ +from buildstream import BuildElement, SandboxFlags + + +class DeprecatedPlugin(BuildElement): + BST_PLUGIN_DEPRECATED = True + BST_PLUGIN_DEPRECATION_MESSAGE = "Here is some detail." + + +# Plugin entry point +def setup(): + return DeprecatedPlugin diff --git a/tests/plugins/deprecationwarnings/project/plugins/elements/deprecated_plugin.yaml b/tests/plugins/deprecationwarnings/project/plugins/elements/deprecated_plugin.yaml new file mode 100644 index 000000000..1c07cd8b2 --- /dev/null +++ b/tests/plugins/deprecationwarnings/project/plugins/elements/deprecated_plugin.yaml @@ -0,0 +1,22 @@ +# Deprecated-plugin build element does not provide any default +# build commands +config: + + # Commands for configuring the software + # + configure-commands: [] + + # Commands for building the software + # + build-commands: [] + + # Commands for installing the software into a + # destination folder + # + install-commands: [] + + # Commands for stripping installed binaries + # + strip-commands: + - | + %{strip-binaries}
\ No newline at end of file diff --git a/tests/plugins/deprecationwarnings/project/project.conf b/tests/plugins/deprecationwarnings/project/project.conf new file mode 100644 index 000000000..18e368fe9 --- /dev/null +++ b/tests/plugins/deprecationwarnings/project/project.conf @@ -0,0 +1,15 @@ +# Unique project name +name: deprecation-warnings + +# Required BuildStream format version +format-version: 20 + +# Subdirectory where elements are stored +element-path: elements + +plugins: + +- origin: local + path: plugins/elements + elements: + deprecated_plugin: 0 |