Tristan Van Berkom pushed to branch tristan/organizing-tests at BuildStream / buildstream
Commits:
-
b4dfe0d1
by Tristan Van Berkom at 2019-01-11T19:54:15Z
-
1181c0f9
by Tristan Van Berkom at 2019-01-11T19:54:15Z
-
fec9f850
by Tristan Van Berkom at 2019-01-11T19:54:15Z
-
e1ddf5fa
by Tristan Van Berkom at 2019-01-11T19:54:15Z
13 changed files:
- tests/format/project.py
- tests/pipeline/preflight-error/error.bst → tests/format/project/plugin-preflight-error/error.bst
- tests/pipeline/preflight-error/errorplugin/__init__.py → tests/format/project/plugin-preflight-error/errorplugin/__init__.py
- tests/pipeline/preflight-error/errorplugin/preflighterror.py → tests/format/project/plugin-preflight-error/errorplugin/preflighterror.py
- tests/pipeline/preflight-error/project.conf → tests/format/project/plugin-preflight-error/project.conf
- tests/format/variables.py
- tests/loader/variables/simple/foo.txt → tests/format/variables/protected-vars/foo.txt
- tests/loader/variables/simple/project.conf → tests/format/variables/protected-vars/project.conf
- − tests/loader/variables.py
- − tests/pipeline/load.py
- − tests/pipeline/load/simple/project.conf
- − tests/pipeline/load/simple/simple.bst
- − tests/pipeline/preflight.py
Changes:
... | ... | @@ -140,7 +140,7 @@ def test_local_plugin_not_directory(cli, datafiles): |
140 | 140 |
|
141 | 141 |
|
142 | 142 |
@pytest.mark.datafiles(DATA_DIR)
|
143 |
-def test_project_plugin_load_allowed(cli, datafiles):
|
|
143 |
+def test_plugin_load_allowed(cli, datafiles):
|
|
144 | 144 |
project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-allowed')
|
145 | 145 |
result = cli.run(project=project, silent=True, args=[
|
146 | 146 |
'show', 'element.bst'])
|
... | ... | @@ -148,7 +148,7 @@ def test_project_plugin_load_allowed(cli, datafiles): |
148 | 148 |
|
149 | 149 |
|
150 | 150 |
@pytest.mark.datafiles(DATA_DIR)
|
151 |
-def test_project_plugin_load_forbidden(cli, datafiles):
|
|
151 |
+def test_plugin_load_forbidden(cli, datafiles):
|
|
152 | 152 |
project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-forbidden')
|
153 | 153 |
result = cli.run(project=project, silent=True, args=[
|
154 | 154 |
'show', 'element.bst'])
|
... | ... | @@ -157,7 +157,7 @@ def test_project_plugin_load_forbidden(cli, datafiles): |
157 | 157 |
|
158 | 158 |
@pytest.mark.datafiles(DATA_DIR)
|
159 | 159 |
@pytest.mark.parametrize("ref_storage", [('inline'), ('project.refs')])
|
160 |
-def test_project_plugin_no_load_ref(cli, datafiles, ref_storage):
|
|
160 |
+def test_plugin_no_load_ref(cli, datafiles, ref_storage):
|
|
161 | 161 |
project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-no-load-ref')
|
162 | 162 |
|
163 | 163 |
# Generate project with access to the noloadref plugin and project.refs enabled
|
... | ... | @@ -188,7 +188,14 @@ def test_project_plugin_no_load_ref(cli, datafiles, ref_storage): |
188 | 188 |
|
189 | 189 |
|
190 | 190 |
@pytest.mark.datafiles(DATA_DIR)
|
191 |
-def test_project_conf_duplicate_plugins(cli, datafiles):
|
|
191 |
+def test_plugin_preflight_error(cli, datafiles, tmpdir):
|
|
192 |
+ project = os.path.join(datafiles.dirname, datafiles.basename, 'plugin-preflight-error')
|
|
193 |
+ result = cli.run(project=project, args=['source', 'fetch', 'error.bst'])
|
|
194 |
+ result.assert_main_error(ErrorDomain.SOURCE, "the-preflight-error")
|
|
195 |
+ |
|
196 |
+ |
|
197 |
+@pytest.mark.datafiles(DATA_DIR)
|
|
198 |
+def test_duplicate_plugins(cli, datafiles):
|
|
192 | 199 |
project = os.path.join(datafiles.dirname, datafiles.basename, 'duplicate-plugins')
|
193 | 200 |
result = cli.run(project=project, silent=True, args=[
|
194 | 201 |
'show', 'element.bst'])
|
... | ... | @@ -12,6 +12,14 @@ DATA_DIR = os.path.join( |
12 | 12 |
"variables"
|
13 | 13 |
)
|
14 | 14 |
|
15 |
+# List of BuildStream protected variables
|
|
16 |
+PROTECTED_VARIABLES = [('project-name'), ('element-name'), ('max-jobs')]
|
|
17 |
+ |
|
18 |
+ |
|
19 |
+def print_warning(msg):
|
|
20 |
+ RED, END = "\033[91m", "\033[0m"
|
|
21 |
+ print(("\n{}{}{}").format(RED, msg, END), file=sys.stderr)
|
|
22 |
+ |
|
15 | 23 |
|
16 | 24 |
###############################################################
|
17 | 25 |
# Test proper loading of some default commands from plugins #
|
... | ... | @@ -87,6 +95,84 @@ def test_cyclic_variables(cli, datafiles): |
87 | 95 |
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.RECURSIVE_VARIABLE)
|
88 | 96 |
|
89 | 97 |
|
90 |
-def print_warning(msg):
|
|
91 |
- RED, END = "\033[91m", "\033[0m"
|
|
92 |
- print(("\n{}{}{}").format(RED, msg, END), file=sys.stderr)
|
|
98 |
+@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
|
|
99 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'protected-vars'))
|
|
100 |
+def test_use_of_protected_var_project_conf(cli, tmpdir, datafiles, protected_var):
|
|
101 |
+ project = str(datafiles)
|
|
102 |
+ conf = {
|
|
103 |
+ 'name': 'test',
|
|
104 |
+ 'variables': {
|
|
105 |
+ protected_var: 'some-value'
|
|
106 |
+ }
|
|
107 |
+ }
|
|
108 |
+ _yaml.dump(conf, os.path.join(project, 'project.conf'))
|
|
109 |
+ |
|
110 |
+ element = {
|
|
111 |
+ 'kind': 'import',
|
|
112 |
+ 'sources': [
|
|
113 |
+ {
|
|
114 |
+ 'kind': 'local',
|
|
115 |
+ 'path': 'foo.txt'
|
|
116 |
+ }
|
|
117 |
+ ],
|
|
118 |
+ }
|
|
119 |
+ _yaml.dump(element, os.path.join(project, 'target.bst'))
|
|
120 |
+ |
|
121 |
+ result = cli.run(project=project, args=['build', 'target.bst'])
|
|
122 |
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
123 |
+ LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
|
|
124 |
+ |
|
125 |
+ |
|
126 |
+@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
|
|
127 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'protected-vars'))
|
|
128 |
+def test_use_of_protected_var_element_overrides(cli, tmpdir, datafiles, protected_var):
|
|
129 |
+ project = str(datafiles)
|
|
130 |
+ conf = {
|
|
131 |
+ 'name': 'test',
|
|
132 |
+ 'elements': {
|
|
133 |
+ 'manual': {
|
|
134 |
+ 'variables': {
|
|
135 |
+ protected_var: 'some-value'
|
|
136 |
+ }
|
|
137 |
+ }
|
|
138 |
+ }
|
|
139 |
+ }
|
|
140 |
+ _yaml.dump(conf, os.path.join(project, 'project.conf'))
|
|
141 |
+ |
|
142 |
+ element = {
|
|
143 |
+ 'kind': 'manual',
|
|
144 |
+ 'sources': [
|
|
145 |
+ {
|
|
146 |
+ 'kind': 'local',
|
|
147 |
+ 'path': 'foo.txt'
|
|
148 |
+ }
|
|
149 |
+ ],
|
|
150 |
+ }
|
|
151 |
+ _yaml.dump(element, os.path.join(project, 'target.bst'))
|
|
152 |
+ |
|
153 |
+ result = cli.run(project=project, args=['build', 'target.bst'])
|
|
154 |
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
155 |
+ LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
|
|
156 |
+ |
|
157 |
+ |
|
158 |
+@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
|
|
159 |
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'protected-vars'))
|
|
160 |
+def test_use_of_protected_var_in_element(cli, tmpdir, datafiles, protected_var):
|
|
161 |
+ project = str(datafiles)
|
|
162 |
+ element = {
|
|
163 |
+ 'kind': 'import',
|
|
164 |
+ 'sources': [
|
|
165 |
+ {
|
|
166 |
+ 'kind': 'local',
|
|
167 |
+ 'path': 'foo.txt'
|
|
168 |
+ }
|
|
169 |
+ ],
|
|
170 |
+ 'variables': {
|
|
171 |
+ protected_var: 'some-value'
|
|
172 |
+ }
|
|
173 |
+ }
|
|
174 |
+ _yaml.dump(element, os.path.join(project, 'target.bst'))
|
|
175 |
+ |
|
176 |
+ result = cli.run(project=project, args=['build', 'target.bst'])
|
|
177 |
+ result.assert_main_error(ErrorDomain.LOAD,
|
|
178 |
+ LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
|
1 |
-import os
|
|
2 |
-import pytest
|
|
3 |
- |
|
4 |
-from buildstream import _yaml
|
|
5 |
-from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
|
6 |
-from tests.testutils import cli
|
|
7 |
- |
|
8 |
-DATA_DIR = os.path.join(
|
|
9 |
- os.path.dirname(os.path.realpath(__file__)),
|
|
10 |
- 'variables',
|
|
11 |
-)
|
|
12 |
- |
|
13 |
-PROTECTED_VARIABLES = [('project-name'), ('element-name'), ('max-jobs')]
|
|
14 |
- |
|
15 |
- |
|
16 |
-@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
|
|
17 |
-@pytest.mark.datafiles(DATA_DIR)
|
|
18 |
-def test_use_of_protected_var_project_conf(cli, tmpdir, datafiles, protected_var):
|
|
19 |
- project = os.path.join(str(datafiles), 'simple')
|
|
20 |
- |
|
21 |
- conf = {
|
|
22 |
- 'name': 'test',
|
|
23 |
- 'variables': {
|
|
24 |
- protected_var: 'some-value'
|
|
25 |
- }
|
|
26 |
- }
|
|
27 |
- _yaml.dump(conf, os.path.join(project, 'project.conf'))
|
|
28 |
- |
|
29 |
- element = {
|
|
30 |
- 'kind': 'import',
|
|
31 |
- 'sources': [
|
|
32 |
- {
|
|
33 |
- 'kind': 'local',
|
|
34 |
- 'path': 'foo.txt'
|
|
35 |
- }
|
|
36 |
- ],
|
|
37 |
- }
|
|
38 |
- _yaml.dump(element, os.path.join(project, 'target.bst'))
|
|
39 |
- |
|
40 |
- result = cli.run(project=project, args=['build', 'target.bst'])
|
|
41 |
- result.assert_main_error(ErrorDomain.LOAD,
|
|
42 |
- LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
|
|
43 |
- |
|
44 |
- |
|
45 |
-@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
|
|
46 |
-@pytest.mark.datafiles(DATA_DIR)
|
|
47 |
-def test_use_of_protected_var_element_overrides(cli, tmpdir, datafiles, protected_var):
|
|
48 |
- project = os.path.join(str(datafiles), 'simple')
|
|
49 |
- |
|
50 |
- conf = {
|
|
51 |
- 'name': 'test',
|
|
52 |
- 'elements': {
|
|
53 |
- 'manual': {
|
|
54 |
- 'variables': {
|
|
55 |
- protected_var: 'some-value'
|
|
56 |
- }
|
|
57 |
- }
|
|
58 |
- }
|
|
59 |
- }
|
|
60 |
- _yaml.dump(conf, os.path.join(project, 'project.conf'))
|
|
61 |
- |
|
62 |
- element = {
|
|
63 |
- 'kind': 'manual',
|
|
64 |
- 'sources': [
|
|
65 |
- {
|
|
66 |
- 'kind': 'local',
|
|
67 |
- 'path': 'foo.txt'
|
|
68 |
- }
|
|
69 |
- ],
|
|
70 |
- }
|
|
71 |
- _yaml.dump(element, os.path.join(project, 'target.bst'))
|
|
72 |
- |
|
73 |
- result = cli.run(project=project, args=['build', 'target.bst'])
|
|
74 |
- result.assert_main_error(ErrorDomain.LOAD,
|
|
75 |
- LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
|
|
76 |
- |
|
77 |
- |
|
78 |
-@pytest.mark.parametrize('protected_var', PROTECTED_VARIABLES)
|
|
79 |
-@pytest.mark.datafiles(DATA_DIR)
|
|
80 |
-def test_use_of_protected_var_in_element(cli, tmpdir, datafiles, protected_var):
|
|
81 |
- project = os.path.join(str(datafiles), 'simple')
|
|
82 |
- |
|
83 |
- element = {
|
|
84 |
- 'kind': 'import',
|
|
85 |
- 'sources': [
|
|
86 |
- {
|
|
87 |
- 'kind': 'local',
|
|
88 |
- 'path': 'foo.txt'
|
|
89 |
- }
|
|
90 |
- ],
|
|
91 |
- 'variables': {
|
|
92 |
- protected_var: 'some-value'
|
|
93 |
- }
|
|
94 |
- }
|
|
95 |
- _yaml.dump(element, os.path.join(project, 'target.bst'))
|
|
96 |
- |
|
97 |
- result = cli.run(project=project, args=['build', 'target.bst'])
|
|
98 |
- result.assert_main_error(ErrorDomain.LOAD,
|
|
99 |
- LoadErrorReason.PROTECTED_VARIABLE_REDEFINED)
|
1 |
-import os
|
|
2 |
-import pytest
|
|
3 |
-from buildstream._exceptions import ErrorDomain
|
|
4 |
-from buildstream import _yaml
|
|
5 |
-from tests.testutils.runcli import cli
|
|
6 |
- |
|
7 |
-DATA_DIR = os.path.join(
|
|
8 |
- os.path.dirname(os.path.realpath(__file__)),
|
|
9 |
- 'load',
|
|
10 |
-)
|
|
11 |
- |
|
12 |
- |
|
13 |
-@pytest.mark.datafiles(os.path.join(DATA_DIR, 'simple'))
|
|
14 |
-def test_load_simple(cli, datafiles):
|
|
15 |
- basedir = os.path.join(datafiles.dirname, datafiles.basename)
|
|
16 |
- result = cli.get_element_config(basedir, 'simple.bst')
|
|
17 |
- |
|
18 |
- assert(result['configure-commands'][0] == 'pony')
|
1 |
-# Basic project configuration that doesnt override anything
|
|
2 |
-#
|
|
3 |
-name: pony
|
1 |
-kind: autotools
|
|
2 |
-description: Some kinda autotools element
|
|
3 |
-config:
|
|
4 |
- configure-commands:
|
|
5 |
- - pony
|
1 |
-import os
|
|
2 |
-import pytest
|
|
3 |
- |
|
4 |
-from buildstream._exceptions import ErrorDomain
|
|
5 |
-from tests.testutils.runcli import cli
|
|
6 |
- |
|
7 |
-DATA_DIR = os.path.join(
|
|
8 |
- os.path.dirname(os.path.realpath(__file__)),
|
|
9 |
- 'preflight-error',
|
|
10 |
-)
|
|
11 |
- |
|
12 |
- |
|
13 |
-@pytest.mark.datafiles(DATA_DIR)
|
|
14 |
-def test_load_simple(cli, datafiles, tmpdir):
|
|
15 |
- basedir = os.path.join(datafiles.dirname, datafiles.basename)
|
|
16 |
- |
|
17 |
- # Lets try to fetch it...
|
|
18 |
- result = cli.run(project=basedir, args=['source', 'fetch', 'error.bst'])
|
|
19 |
- result.assert_main_error(ErrorDomain.SOURCE, "the-preflight-error")
|