summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/buildstream/_context.py3
-rw-r--r--tests/format/userconfig.py25
2 files changed, 27 insertions, 1 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py
index 879555089..4e1007e28 100644
--- a/src/buildstream/_context.py
+++ b/src/buildstream/_context.py
@@ -367,7 +367,8 @@ class Context():
# Shallow validation of overrides, parts of buildstream which rely
# on the overrides are expected to validate elsewhere.
- for overrides in self._project_overrides.values():
+ for overrides_project in self._project_overrides.keys():
+ overrides = self._project_overrides.get_mapping(overrides_project)
overrides.validate_keys(['artifacts', 'source-caches', 'options',
'strict', 'default-mirror',
'remote-execution'])
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)