Exemplo n.º 1
0
def test_SnapcraftExperimentalExtensionsRequiredError():
    error = errors.SnapcraftExperimentalExtensionsRequiredError(
        extension_name="foo")

    assert (error.get_brief() ==
            "Experimental extension 'foo' is required, but not enabled.")
    assert error.get_details() is None
    assert (
        error.get_resolution() ==
        "This extension may be enabled with the '--enable-experimental-extensions' parameter."
    )
    assert error.get_docs_url() is None
    assert error.get_exit_code() == 2
Exemplo n.º 2
0
def _load_extension(base: Optional[str], extension_name: str,
                    yaml_data: Dict[str, Any]) -> Extension:
    extension_class = find_extension(extension_name)

    if extension_class.is_experimental(base=base):
        if os.getenv("SNAPCRAFT_ENABLE_EXPERIMENTAL_EXTENSIONS"):
            logger.warning(
                f"*EXPERIMENTAL* extension {extension_name!r} enabled.")
        else:
            raise project_errors.SnapcraftExperimentalExtensionsRequiredError(
                extension_name=extension_name)

    # Hand the extension a copy of the yaml data so the only way they can modify it is
    # by going through the extension API.
    return extension_class(extension_name=extension_name,
                           yaml_data=copy.deepcopy(yaml_data))