[Notes] [Git][BuildStream/buildstream][phil/848-plugin-deprecation-warnings] fixup! plugin.py: Add API to allow plugins to raise deprecation warnings



Title: GitLab

Phil Dawson pushed to branch phil/848-plugin-deprecation-warnings at BuildStream / buildstream

Commits:

5 changed files:

Changes:

  • tests/plugins/basics/deprecationwarnings/deprecationwarnings.py
    1 1
     import pytest
    
    2 2
     import tempfile
    
    3 3
     import os
    
    4
    +from tests.testutils import cli
    
    5
    +import buildstream.plugins.elements.manual
    
    4 6
     
    
    5
    -from tests.testutils import cli, generate_junction
    
    6
    -from buildstream import _yaml
    
    7
    -import buildstream.plugins.elements.manual as manual
    
    8 7
     
    
    8
    +DATA_DIR = os.path.join(
    
    9
    +    os.path.dirname(os.path.realpath(__file__)),
    
    10
    +    "project"
    
    11
    +)
    
    9 12
     
    
    10 13
     _DEPRECATION_MESSAGE = "Here is some detail."
    
    14
    +_DEPRECATION_WARNING = "Using deprecated plugin deprecated_plugin: {}".format(_DEPRECATION_MESSAGE)
    
    11 15
     
    
    16
    +@pytest.mark.datafiles(DATA_DIR)
    
    17
    +def test_deprecation_warning_present(cli, datafiles):
    
    18
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    19
    +    result = cli.run(project=project, args=['show', 'deprecated.bst'])
    
    20
    +    result.assert_success()
    
    21
    +    assert _DEPRECATION_WARNING in result.stderr
    
    12 22
     
    
    13
    -def test_deprecation_warning_present(cli):
    
    23
    +@pytest.mark.datafiles(DATA_DIR)
    
    24
    +def test_supress_deprecation_warning(cli, datafiles):
    
    25
    +    project = os.path.join(datafiles.dirname, datafiles.basename)
    
    26
    +    result = cli.run(project=project, args=['show', 'manual.bst'])
    
    14 27
     
    
    15
    -    manual.ManualElement.BST_PLUGIN_DEPRECATED = True
    
    16
    -    manual.ManualElement.BST_PLUGIN_DEPRECATION_MESSAGE = _DEPRECATION_MESSAGE
    
    28
    +    project_conf = os.path.join(project, 'project.conf')
    
    29
    +    with open(project_conf, 'a') as f:
    
    30
    +        f.write('\nsupress-deprecation-warnings: [deprecated_plugin]')
    
    17 31
     
    
    18
    -    with tempfile.TemporaryDirectory() as project:
    
    19
    -        result = cli.run(project=project, args=['init', '--project-name', 'deprectedplugins'])
    
    20
    -        result.assert_success()
    
    32
    +    result = cli.run(project=project, args=['show', 'deprecated.bst'])
    
    21 33
     
    
    22
    -        manual_element = os.path.join(project, 'elements', 'manual.bst')
    
    23
    -        with open(manual_element, 'w') as f:
    
    24
    -            f.write('kind: manual')
    
    25
    -
    
    26
    -
    
    27
    -        result = cli.run(project=project, args=['show', 'manual.bst'])
    
    28
    -
    
    29
    -        result.assert_success()
    
    30
    -        expected_warning = "Using deprecated plugin manual: {}".format(_DEPRECATION_MESSAGE)
    
    31
    -        assert expected_warning in result.stderr
    
    32
    -
    
    33
    -
    
    34
    -def test_supress_deprecation_warning(cli):
    
    35
    -
    
    36
    -    manual.ManualElement.BST_PLUGIN_DEPRECATED = True
    
    37
    -    manual.ManualElement.BST_PLUGIN_DEPRECATION_MESSAGE = _DEPRECATION_MESSAGE
    
    38
    -
    
    39
    -    with tempfile.TemporaryDirectory() as project:
    
    40
    -        result = cli.run(project=project, args=['init', '--project-name', 'deprectedplugins'])
    
    41
    -        result.assert_success()
    
    42
    -
    
    43
    -        project_conf = os.path.join(project, 'project.conf')
    
    44
    -        with open(project_conf, 'a') as f:
    
    45
    -            f.write("\nsupress-deprecation-warnings: [manual]")
    
    46
    -
    
    47
    -        manual_element = os.path.join(project, 'elements', 'manual.bst')
    
    48
    -        with open(manual_element, 'w') as f:
    
    49
    -            f.write('kind: manual')
    
    50
    -
    
    51
    -
    
    52
    -        result = cli.run(project=project, args=['show', 'manual.bst'])
    
    53
    -
    
    54
    -        result.assert_success()
    
    55
    -        expected_warning = "Using deprecated plugin manual: {}".format(_DEPRECATION_MESSAGE)
    
    56
    -        assert not expected_warning in result.stderr
    34
    +    result.assert_success()
    
    35
    +    assert _DEPRECATION_WARNING not in result.stderr

  • tests/plugins/basics/deprecationwarnings/project/elements/deprecated.bst
    1
    +kind: deprecated_plugin
    \ No newline at end of file

  • tests/plugins/basics/deprecationwarnings/project/plugins/elements/deprecated_plugin.py
    1
    +from buildstream import BuildElement, SandboxFlags
    
    2
    +
    
    3
    +class DeprecatedPlugin(BuildElement):
    
    4
    +    BST_PLUGIN_DEPRECATED = True
    
    5
    +    BST_PLUGIN_DEPRECATION_MESSAGE = "Here is some detail."
    
    6
    +        
    
    7
    +# Plugin entry point
    
    8
    +def setup():
    
    9
    +    return DeprecatedPlugin

  • tests/plugins/basics/deprecationwarnings/project/plugins/elements/deprecated_plugin.yaml
    1
    +# Deprecated-plugin build element does not provide any default
    
    2
    +# build commands
    
    3
    +config:
    
    4
    +
    
    5
    +  # Commands for configuring the software
    
    6
    +  #
    
    7
    +  configure-commands: []
    
    8
    +
    
    9
    +  # Commands for building the software
    
    10
    +  #
    
    11
    +  build-commands: []
    
    12
    +
    
    13
    +  # Commands for installing the software into a
    
    14
    +  # destination folder
    
    15
    +  #
    
    16
    +  install-commands: []
    
    17
    +
    
    18
    +  # Commands for stripping installed binaries
    
    19
    +  #
    
    20
    +  strip-commands:
    
    21
    +  - |
    
    22
    +    %{strip-binaries}
    \ No newline at end of file

  • tests/plugins/basics/deprecationwarnings/project/project.conf
    1
    +# Unique project name
    
    2
    +name: deprecation-warnings
    
    3
    +
    
    4
    +# Required BuildStream format version
    
    5
    +format-version: 20
    
    6
    +
    
    7
    +# Subdirectory where elements are stored
    
    8
    +element-path: elements
    
    9
    +
    
    10
    +plugins:
    
    11
    +
    
    12
    +- origin: local
    
    13
    +  path: plugins/elements
    
    14
    +  elements:
    
    15
    +    deprecated_plugin: 0



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]