diff options
author | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-06-05 19:13:15 +0900 |
---|---|---|
committer | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-06-08 23:50:34 +0900 |
commit | 5a2a9f4da08ff3b6f952683f970fc0f8c16e1b67 (patch) | |
tree | 56e999cda819e645169f9d2c07aea4bd59ab972b /tests | |
parent | d7242d40824e058eff00bb13fe83debf24dad8be (diff) | |
download | buildstream-5a2a9f4da08ff3b6f952683f970fc0f8c16e1b67.tar.gz |
tests/plugins/loading.py: Testing junction plugins with full paths
Added tests to cover:
* Successfully loading plugins with full paths in junction origins
* Failing to load missing plugins in sub-junctions which are successfully loaded
* Failing to load missing plugins in sub-junctions which are invalid and couldnt load
Diffstat (limited to 'tests')
-rw-r--r-- | tests/plugins/loading.py | 110 |
1 files changed, 109 insertions, 1 deletions
diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py index 63a2ca3d4..7aeb242f3 100644 --- a/tests/plugins/loading.py +++ b/tests/plugins/loading.py @@ -10,7 +10,7 @@ import os import shutil import pytest -from buildstream.exceptions import ErrorDomain +from buildstream.exceptions import ErrorDomain, LoadErrorReason from buildstream.testing import cli # pylint: disable=unused-import from buildstream import _yaml @@ -599,3 +599,111 @@ def test_junction_pip_plugin_version_conflict(cli, datafiles, plugin_type): result = cli.run(project=project, args=["show", "element.bst"]) result.assert_main_error(ErrorDomain.PLUGIN, "junction-plugin-load-error") + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")]) +def test_junction_full_path_found(cli, datafiles, plugin_type): + project = str(datafiles) + subproject = os.path.join(project, "subproject") + subsubproject = os.path.join(subproject, "subsubproject") + + shutil.copytree(os.path.join(project, "plugins"), os.path.join(subsubproject, "plugins")) + + update_project( + project, + { + "plugins": [ + { + "origin": "junction", + "junction": "subproject-junction.bst:subsubproject-junction.bst", + plugin_type: ["found"], + } + ] + }, + ) + update_project( + subsubproject, + { + "plugins": [ + {"origin": "local", "path": os.path.join("plugins", plugin_type, "found"), plugin_type: ["found"],} + ] + }, + ) + setup_element(project, plugin_type, "found") + + result = cli.run(project=project, args=["show", "element.bst"]) + result.assert_success() + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize("plugin_type", [("elements"), ("sources")]) +def test_junction_full_path_not_found(cli, datafiles, plugin_type): + project = str(datafiles) + subproject = os.path.join(project, "subproject") + subsubproject = os.path.join(subproject, "subsubproject") + + shutil.copytree(os.path.join(project, "plugins"), os.path.join(subsubproject, "plugins")) + + # The toplevel says to search for the "notfound" plugin in the subproject + # + update_project( + project, + { + "plugins": [ + { + "origin": "junction", + "junction": "subproject-junction.bst:subsubproject-junction.bst", + plugin_type: ["notfound"], + } + ] + }, + ) + + # The subsubproject only configures the "found" plugin + # + update_project( + subsubproject, + { + "plugins": [ + {"origin": "local", "path": os.path.join("plugins", plugin_type, "found"), plugin_type: ["found"],} + ] + }, + ) + setup_element(project, plugin_type, "notfound") + + result = cli.run(project=project, args=["show", "element.bst"]) + result.assert_main_error(ErrorDomain.PLUGIN, "junction-plugin-not-found") + + +@pytest.mark.datafiles(DATA_DIR) +@pytest.mark.parametrize( + "plugin_type,provenance", + [("elements", "project.conf [line 10 column 2]"), ("sources", "project.conf [line 10 column 2]")], +) +def test_junction_invalid_full_path(cli, datafiles, plugin_type, provenance): + project = str(datafiles) + subproject = os.path.join(project, "subproject") + subsubproject = os.path.join(subproject, "subsubproject") + + shutil.copytree(os.path.join(project, "plugins"), os.path.join(subsubproject, "plugins")) + + # The toplevel says to search for the "notfound" plugin in the subproject + # + update_project( + project, + { + "plugins": [ + { + "origin": "junction", + "junction": "subproject-junction.bst:pony-junction.bst", + plugin_type: ["notfound"], + } + ] + }, + ) + setup_element(project, plugin_type, "notfound") + + result = cli.run(project=project, args=["show", "element.bst"]) + result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE) + assert provenance in result.stderr |