summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-11-05 12:11:03 +0000
committerBenjamin Schubert <contact@benschubert.me>2019-11-05 12:11:03 +0000
commit8fe7d261d1aca884526438ee1bd649056b47b050 (patch)
tree285c28f1e2c8431ad6d140e0f1b6c190f129c767 /tests
parent247f37548855bd716c4e15508ed5ae33073a868f (diff)
downloadbuildstream-8fe7d261d1aca884526438ee1bd649056b47b050.tar.gz
_context.py: Improve reporting of incorrect user configbschubert/better-reporting-on-userconfig
This fixes a case where, in project overrides, if a user specified a scalar/sequence instead of a mapping for a given project, the user would receive an ugly stacktrace instead of an invalid format.
Diffstat (limited to 'tests')
-rw-r--r--tests/format/userconfig.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/format/userconfig.py b/tests/format/userconfig.py
new file mode 100644
index 000000000..72172a24d
--- /dev/null
+++ b/tests/format/userconfig.py
@@ -0,0 +1,25 @@
+# Pylint doesn't play well with fixtures and dependency injection from pytest
+# pylint: disable=redefined-outer-name
+
+import os
+
+import pytest
+
+from buildstream._exceptions import ErrorDomain, LoadErrorReason
+from buildstream.testing.runcli import cli # pylint: disable=unused-import
+
+# Project directory
+DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "project")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_ensure_misformed_project_overrides_give_sensible_errors(cli, datafiles):
+ userconfig = {
+ "projects": {
+ "test": []
+ }
+ }
+ cli.configure(userconfig)
+
+ result = cli.run(project=datafiles, args=["show"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)