Qinusty pushed to branch Qinusty/526-fail-on-warnings at BuildStream / buildstream
Commits:
-
45a5c370
by Josh Smith at 2018-08-10T23:38:53Z
8 changed files:
- + tests/frontend/configurable_warnings.py
- + tests/frontend/configuredwarning/elements/corewarn.bst
- + tests/frontend/configuredwarning/elements/warninga.bst
- + tests/frontend/configuredwarning/elements/warningb.bst
- + tests/frontend/configuredwarning/plugins/corewarn.py
- + tests/frontend/configuredwarning/plugins/warninga.py
- + tests/frontend/configuredwarning/plugins/warningb.py
- + tests/frontend/configuredwarning/project.conf
Changes:
1 |
+import pytest
|
|
2 |
+import os
|
|
3 |
+ |
|
4 |
+from buildstream.plugin import CoreWarnings
|
|
5 |
+from buildstream._exceptions import ErrorDomain, LoadErrorReason
|
|
6 |
+from buildstream import _yaml
|
|
7 |
+from tests.testutils.runcli import cli
|
|
8 |
+ |
|
9 |
+TOP_DIR = os.path.join(
|
|
10 |
+ os.path.dirname(os.path.realpath(__file__)),
|
|
11 |
+ "configuredwarning"
|
|
12 |
+)
|
|
13 |
+ |
|
14 |
+ |
|
15 |
+def get_project(fatal_warnings):
|
|
16 |
+ return {
|
|
17 |
+ "name": "test",
|
|
18 |
+ "element-path": "elements",
|
|
19 |
+ "plugins": [
|
|
20 |
+ {
|
|
21 |
+ "origin": "local",
|
|
22 |
+ "path": "plugins",
|
|
23 |
+ "elements": {
|
|
24 |
+ "warninga": 0,
|
|
25 |
+ "warningb": 0,
|
|
26 |
+ "corewarn": 0,
|
|
27 |
+ }
|
|
28 |
+ }
|
|
29 |
+ ],
|
|
30 |
+ "fatal-warnings": fatal_warnings
|
|
31 |
+ }
|
|
32 |
+ |
|
33 |
+ |
|
34 |
+def build_project(datafiles, fatal_warnings):
|
|
35 |
+ project_path = os.path.join(datafiles.dirname, datafiles.basename)
|
|
36 |
+ |
|
37 |
+ project = get_project(fatal_warnings)
|
|
38 |
+ |
|
39 |
+ _yaml.dump(project, os.path.join(project_path, "project.conf"))
|
|
40 |
+ |
|
41 |
+ return project_path
|
|
42 |
+ |
|
43 |
+ |
|
44 |
+@pytest.mark.datafiles(TOP_DIR)
|
|
45 |
+@pytest.mark.parametrize("element_name, fatal_warnings, expect_fatal, error_domain", [
|
|
46 |
+ ("corewarn.bst", [CoreWarnings.OVERLAPS], True, ErrorDomain.STREAM),
|
|
47 |
+ ("warninga.bst", ["warninga:warning-a"], True, ErrorDomain.STREAM),
|
|
48 |
+ ("warningb.bst", ["warningb:warning-b"], True, ErrorDomain.STREAM),
|
|
49 |
+ ("corewarn.bst", [], False, None),
|
|
50 |
+ ("warninga.bst", [], False, None),
|
|
51 |
+ ("warningb.bst", [], False, None),
|
|
52 |
+ ("corewarn.bst", "true", True, ErrorDomain.STREAM),
|
|
53 |
+ ("warninga.bst", "true", True, ErrorDomain.STREAM),
|
|
54 |
+ ("warningb.bst", "true", True, ErrorDomain.STREAM),
|
|
55 |
+ ("warninga.bst", [CoreWarnings.OVERLAPS], False, None),
|
|
56 |
+ ("warningb.bst", [CoreWarnings.OVERLAPS], False, None),
|
|
57 |
+])
|
|
58 |
+def test_fatal_warnings(cli, datafiles, element_name,
|
|
59 |
+ fatal_warnings, expect_fatal, error_domain):
|
|
60 |
+ project_path = build_project(datafiles, fatal_warnings)
|
|
61 |
+ |
|
62 |
+ result = cli.run(project=project_path, args=["build", element_name])
|
|
63 |
+ if expect_fatal:
|
|
64 |
+ result.assert_main_error(error_domain, None, "Expected fatal execution")
|
|
65 |
+ else:
|
|
66 |
+ result.assert_success("Unexpected fatal execution")
|
1 |
+kind: corewarn
|
|
\ No newline at end of file |
1 |
+kind: warninga
|
1 |
+kind: warningb
|
1 |
+from buildstream import Element
|
|
2 |
+from buildstream.plugin import CoreWarnings
|
|
3 |
+ |
|
4 |
+ |
|
5 |
+class CoreWarn(Element):
|
|
6 |
+ def configure(self, node):
|
|
7 |
+ pass
|
|
8 |
+ |
|
9 |
+ def preflight(self):
|
|
10 |
+ pass
|
|
11 |
+ |
|
12 |
+ def get_unique_key(self):
|
|
13 |
+ pass
|
|
14 |
+ |
|
15 |
+ def configure_sandbox(self, sandbox):
|
|
16 |
+ pass
|
|
17 |
+ |
|
18 |
+ def stage(self, sandbox):
|
|
19 |
+ pass
|
|
20 |
+ |
|
21 |
+ def assemble(self, sandbox):
|
|
22 |
+ self.warn("Testing: CoreWarning produced during assemble",
|
|
23 |
+ warning_token=CoreWarnings.OVERLAPS)
|
|
24 |
+ |
|
25 |
+ |
|
26 |
+def setup():
|
|
27 |
+ return CoreWarn
|
1 |
+from buildstream import Element
|
|
2 |
+ |
|
3 |
+WARNING_A = "warning-a"
|
|
4 |
+ |
|
5 |
+ |
|
6 |
+class WarningA(Element):
|
|
7 |
+ def configure(self, node):
|
|
8 |
+ pass
|
|
9 |
+ |
|
10 |
+ def preflight(self):
|
|
11 |
+ pass
|
|
12 |
+ |
|
13 |
+ def get_unique_key(self):
|
|
14 |
+ pass
|
|
15 |
+ |
|
16 |
+ def configure_sandbox(self, sandbox):
|
|
17 |
+ pass
|
|
18 |
+ |
|
19 |
+ def stage(self, sandbox):
|
|
20 |
+ pass
|
|
21 |
+ |
|
22 |
+ def assemble(self, sandbox):
|
|
23 |
+ self.warn("Testing: warning-a produced during assemble", warning_token=WARNING_A)
|
|
24 |
+ |
|
25 |
+ |
|
26 |
+def setup():
|
|
27 |
+ return WarningA
|
1 |
+from buildstream import Element
|
|
2 |
+ |
|
3 |
+WARNING_B = "warning-b"
|
|
4 |
+ |
|
5 |
+ |
|
6 |
+class WarningB(Element):
|
|
7 |
+ def configure(self, node):
|
|
8 |
+ pass
|
|
9 |
+ |
|
10 |
+ def preflight(self):
|
|
11 |
+ pass
|
|
12 |
+ |
|
13 |
+ def get_unique_key(self):
|
|
14 |
+ pass
|
|
15 |
+ |
|
16 |
+ def configure_sandbox(self, sandbox):
|
|
17 |
+ pass
|
|
18 |
+ |
|
19 |
+ def stage(self, sandbox):
|
|
20 |
+ pass
|
|
21 |
+ |
|
22 |
+ def assemble(self, sandbox):
|
|
23 |
+ self.warn("Testing: warning-b produced during assemble", warning_token=WARNING_B)
|
|
24 |
+ |
|
25 |
+ |
|
26 |
+def setup():
|
|
27 |
+ return WarningB
|
1 |
+name: test
|
|
2 |
+element-path: elements
|
|
3 |
+plugins:
|
|
4 |
+- origin: local
|
|
5 |
+ path: element_plugins
|
|
6 |
+ elements:
|
|
7 |
+ warninga: 0
|
|
8 |
+ warningb: 0
|