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
|