blob: c94743c334989a3c8f42dd1bb75bc0163949118d [file] [log] [blame]
# Pylint doesn't play well with fixtures and dependency injection from pytest
# pylint: disable=redefined-outer-name
# This test case ensures that user provided plugins appropriately shadow
# core defined plugins, which is a behavior that is required in order to
# make it safe for BuildStream to add more plugins in the future without
# stomping on plugin namespace.
import os
import pytest
from buildstream._testing import cli # pylint: disable=unused-import
from buildstream import _yaml
DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "shadow")
def update_project(project_path, updated_configuration):
project_conf_path = os.path.join(project_path, "project.conf")
project_conf = _yaml.roundtrip_load(project_conf_path)
_yaml.roundtrip_dump(project_conf, project_conf_path)
# Run the test with and without shadowing the "manual" plugin.
@pytest.mark.parametrize("shadow", [True, False], ids=["shadowed", "not-shadowed"])
def test_manual(cli, datafiles, shadow):
project = str(datafiles)
if shadow:
update_project(project, {"plugins": [{"origin": "local", "path": "plugins", "elements": ["manual"]}]})
result =, args=["show", "manual.bst"])
if shadow:
assert "This is an overridden manual element" in result.stderr
assert "This is an overridden manual element" not in result.stderr