summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbderrahim Kitouni <akitouni@gnome.org>2020-03-18 11:54:47 +0100
committerAbderrahim Kitouni <akitouni@gnome.org>2020-04-05 20:18:49 +0100
commit7715d08cf7e1b9bfb99674ed0d983a1a12dfae27 (patch)
tree3a6864a9c3764f2f9811518703f9ec45510ee0eb
parentec4a9fe9debb1d506a739f1b65748c8b612d7a09 (diff)
downloadbuildstream-abderrahim/options-1.tar.gz
_project.py: resolve options before running the final assertionsabderrahim/options-1
otherwise, having an optional list append in the configuration wouldn't work This also avoids special casing for element and source overrides
-rw-r--r--buildstream/_project.py22
-rw-r--r--tests/format/option-list-directive.py16
-rw-r--r--tests/format/option-list-directive/project.conf18
3 files changed, 43 insertions, 13 deletions
diff --git a/buildstream/_project.py b/buildstream/_project.py
index 66489986e..c5172e210 100644
--- a/buildstream/_project.py
+++ b/buildstream/_project.py
@@ -562,15 +562,6 @@ class Project():
def _load_pass(self, config, output, *,
ignore_unknown=False):
- # Element and Source type configurations will be composited later onto
- # element/source types, so we delete it from here and run our final
- # assertion after.
- output.element_overrides = _yaml.node_get(config, Mapping, 'elements', default_value={})
- output.source_overrides = _yaml.node_get(config, Mapping, 'sources', default_value={})
- config.pop('elements', None)
- config.pop('sources', None)
- _yaml.node_final_assertions(config)
-
self._load_plugin_factories(config, output)
# Load project options
@@ -594,11 +585,16 @@ class Project():
# Now resolve any conditionals in the remaining configuration,
# any conditionals specified for project option declarations,
# or conditionally specifying the project name; will be ignored.
- #
- # Don't forget to also resolve options in the element and source overrides.
output.options.process_node(config)
- output.options.process_node(output.element_overrides)
- output.options.process_node(output.source_overrides)
+
+ # Element and Source type configurations will be composited later onto
+ # element/source types, so we delete it from here and run our final
+ # assertion after.
+ output.element_overrides = _yaml.node_get(config, Mapping, 'elements', default_value={})
+ output.source_overrides = _yaml.node_get(config, Mapping, 'sources', default_value={})
+ config.pop('elements', None)
+ config.pop('sources', None)
+ _yaml.node_final_assertions(config)
# Load base variables
output.base_variables = _yaml.node_get(config, Mapping, 'variables')
diff --git a/tests/format/option-list-directive.py b/tests/format/option-list-directive.py
new file mode 100644
index 000000000..7035f0987
--- /dev/null
+++ b/tests/format/option-list-directive.py
@@ -0,0 +1,16 @@
+import os
+import pytest
+from tests.testutils.runcli import cli
+
+# Project directory
+DATA_DIR = os.path.dirname(os.path.realpath(__file__))
+
+
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("mount_devices", [("true"), ("false")])
+def test_override(cli, datafiles, mount_devices):
+ project = os.path.join(datafiles.dirname, datafiles.basename, "option-list-directive")
+
+ bst_args = ["--option", "shell_mount_devices", mount_devices, "build"]
+ result = cli.run(project=project, silent=True, args=bst_args)
+ result.assert_success()
diff --git a/tests/format/option-list-directive/project.conf b/tests/format/option-list-directive/project.conf
new file mode 100644
index 000000000..5b2b64fe8
--- /dev/null
+++ b/tests/format/option-list-directive/project.conf
@@ -0,0 +1,18 @@
+name: test
+
+options:
+ shell_mount_devices:
+ type: bool
+ description: whether to mount devices in the shell
+ default: false
+
+shell:
+ host-files:
+ - '/etc/passwd'
+ - '/etc/group'
+
+ (?):
+ - shell_mount_devices:
+ host-files:
+ (>):
+ - '/dev/dri'