summaryrefslogtreecommitdiff
path: root/tests/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'tests/frontend')
-rw-r--r--tests/frontend/configurable_warnings.py63
-rw-r--r--tests/frontend/configuredwarning/elements/corewarn.bst1
-rw-r--r--tests/frontend/configuredwarning/elements/warninga.bst1
-rw-r--r--tests/frontend/configuredwarning/elements/warningb.bst1
-rw-r--r--tests/frontend/configuredwarning/plugins/corewarn.py27
-rw-r--r--tests/frontend/configuredwarning/plugins/warninga.py27
-rw-r--r--tests/frontend/configuredwarning/plugins/warningb.py27
-rw-r--r--tests/frontend/configuredwarning/project.conf8
8 files changed, 155 insertions, 0 deletions
diff --git a/tests/frontend/configurable_warnings.py b/tests/frontend/configurable_warnings.py
new file mode 100644
index 000000000..e8a7b6ac8
--- /dev/null
+++ b/tests/frontend/configurable_warnings.py
@@ -0,0 +1,63 @@
+import pytest
+import os
+
+from buildstream.plugin import CoreWarnings
+from buildstream._exceptions import ErrorDomain, LoadErrorReason
+from buildstream import _yaml
+from tests.testutils.runcli import cli
+
+TOP_DIR = os.path.join(
+ os.path.dirname(os.path.realpath(__file__)),
+ "configuredwarning"
+)
+
+
+def get_project(fatal_warnings):
+ return {
+ "name": "test",
+ "element-path": "elements",
+ "plugins": [
+ {
+ "origin": "local",
+ "path": "plugins",
+ "elements": {
+ "warninga": 0,
+ "warningb": 0,
+ "corewarn": 0,
+ }
+ }
+ ],
+ "fatal-warnings": fatal_warnings
+ }
+
+
+def build_project(datafiles, fatal_warnings):
+ project_path = os.path.join(datafiles.dirname, datafiles.basename)
+
+ project = get_project(fatal_warnings)
+
+ _yaml.dump(project, os.path.join(project_path, "project.conf"))
+
+ return project_path
+
+
+@pytest.mark.datafiles(TOP_DIR)
+@pytest.mark.parametrize("element_name, fatal_warnings, expect_fatal, error_domain", [
+ ("corewarn.bst", [CoreWarnings.OVERLAPS], True, ErrorDomain.STREAM),
+ ("warninga.bst", ["warninga:warning-a"], True, ErrorDomain.STREAM),
+ ("warningb.bst", ["warningb:warning-b"], True, ErrorDomain.STREAM),
+ ("corewarn.bst", [], False, None),
+ ("warninga.bst", [], False, None),
+ ("warningb.bst", [], False, None),
+ ("warninga.bst", [CoreWarnings.OVERLAPS], False, None),
+ ("warningb.bst", [CoreWarnings.OVERLAPS], False, None),
+])
+def test_fatal_warnings(cli, datafiles, element_name,
+ fatal_warnings, expect_fatal, error_domain):
+ project_path = build_project(datafiles, fatal_warnings)
+
+ result = cli.run(project=project_path, args=["build", element_name])
+ if expect_fatal:
+ result.assert_main_error(error_domain, None, "Expected fatal execution")
+ else:
+ result.assert_success("Unexpected fatal execution")
diff --git a/tests/frontend/configuredwarning/elements/corewarn.bst b/tests/frontend/configuredwarning/elements/corewarn.bst
new file mode 100644
index 000000000..6eac4e07e
--- /dev/null
+++ b/tests/frontend/configuredwarning/elements/corewarn.bst
@@ -0,0 +1 @@
+kind: corewarn \ No newline at end of file
diff --git a/tests/frontend/configuredwarning/elements/warninga.bst b/tests/frontend/configuredwarning/elements/warninga.bst
new file mode 100644
index 000000000..43c3458a8
--- /dev/null
+++ b/tests/frontend/configuredwarning/elements/warninga.bst
@@ -0,0 +1 @@
+kind: warninga
diff --git a/tests/frontend/configuredwarning/elements/warningb.bst b/tests/frontend/configuredwarning/elements/warningb.bst
new file mode 100644
index 000000000..2def6c5a4
--- /dev/null
+++ b/tests/frontend/configuredwarning/elements/warningb.bst
@@ -0,0 +1 @@
+kind: warningb
diff --git a/tests/frontend/configuredwarning/plugins/corewarn.py b/tests/frontend/configuredwarning/plugins/corewarn.py
new file mode 100644
index 000000000..1f263a0ce
--- /dev/null
+++ b/tests/frontend/configuredwarning/plugins/corewarn.py
@@ -0,0 +1,27 @@
+from buildstream import Element
+from buildstream.plugin import CoreWarnings
+
+
+class CoreWarn(Element):
+ def configure(self, node):
+ pass
+
+ def preflight(self):
+ pass
+
+ def get_unique_key(self):
+ pass
+
+ def configure_sandbox(self, sandbox):
+ pass
+
+ def stage(self, sandbox):
+ pass
+
+ def assemble(self, sandbox):
+ self.warn("Testing: CoreWarning produced during assemble",
+ warning_token=CoreWarnings.OVERLAPS)
+
+
+def setup():
+ return CoreWarn
diff --git a/tests/frontend/configuredwarning/plugins/warninga.py b/tests/frontend/configuredwarning/plugins/warninga.py
new file mode 100644
index 000000000..9fd8dc61b
--- /dev/null
+++ b/tests/frontend/configuredwarning/plugins/warninga.py
@@ -0,0 +1,27 @@
+from buildstream import Element
+
+WARNING_A = "warning-a"
+
+
+class WarningA(Element):
+ def configure(self, node):
+ pass
+
+ def preflight(self):
+ pass
+
+ def get_unique_key(self):
+ pass
+
+ def configure_sandbox(self, sandbox):
+ pass
+
+ def stage(self, sandbox):
+ pass
+
+ def assemble(self, sandbox):
+ self.warn("Testing: warning-a produced during assemble", warning_token=WARNING_A)
+
+
+def setup():
+ return WarningA
diff --git a/tests/frontend/configuredwarning/plugins/warningb.py b/tests/frontend/configuredwarning/plugins/warningb.py
new file mode 100644
index 000000000..64d25ef39
--- /dev/null
+++ b/tests/frontend/configuredwarning/plugins/warningb.py
@@ -0,0 +1,27 @@
+from buildstream import Element
+
+WARNING_B = "warning-b"
+
+
+class WarningB(Element):
+ def configure(self, node):
+ pass
+
+ def preflight(self):
+ pass
+
+ def get_unique_key(self):
+ pass
+
+ def configure_sandbox(self, sandbox):
+ pass
+
+ def stage(self, sandbox):
+ pass
+
+ def assemble(self, sandbox):
+ self.warn("Testing: warning-b produced during assemble", warning_token=WARNING_B)
+
+
+def setup():
+ return WarningB
diff --git a/tests/frontend/configuredwarning/project.conf b/tests/frontend/configuredwarning/project.conf
new file mode 100644
index 000000000..c73d217b8
--- /dev/null
+++ b/tests/frontend/configuredwarning/project.conf
@@ -0,0 +1,8 @@
+name: test
+element-path: elements
+plugins:
+- origin: local
+ path: element_plugins
+ elements:
+ warninga: 0
+ warningb: 0