summaryrefslogtreecommitdiff
path: root/tests/format
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-05-09 17:19:11 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-05-12 00:37:34 +0900
commit1f916d8ba6e6d083849a2bfe7b2c1886b959db2c (patch)
tree3175784f9775168b2d62f36c60ee89983995fb04 /tests/format
parent6a357da53f4903fe2f6703973b7ed3cc4ed4b166 (diff)
downloadbuildstream-1f916d8ba6e6d083849a2bfe7b2c1886b959db2c.tar.gz
Process options in includes files with the options of their junction
Unfortunately the options from main project cannot always be processed in the include processing since project configuration might load option declarations from a separate file. For that reason the result of `Include.process` should still be passed through the option processor. But all options files included from junctioned are already evaluated. This is a backport of Valentin David's work from 86f013dbffa87692250ce1aefd31cecd1559ddd5
Diffstat (limited to 'tests/format')
-rw-r--r--tests/format/include.py58
-rw-r--r--tests/format/include/junction_options/element.bst1
-rw-r--r--tests/format/include/junction_options/project.conf4
-rw-r--r--tests/format/include/junction_options/subproject/extra_conf.yml7
-rw-r--r--tests/format/include/junction_options/subproject/project.conf11
-rw-r--r--tests/format/include/junction_options_deep/element.bst1
-rw-r--r--tests/format/include/junction_options_deep/project.conf4
-rw-r--r--tests/format/include/junction_options_deep/subproject-1/extra_conf.yml2
-rw-r--r--tests/format/include/junction_options_deep/subproject-1/project.conf1
-rw-r--r--tests/format/include/junction_options_deep/subproject-2/extra_conf.yml7
-rw-r--r--tests/format/include/junction_options_deep/subproject-2/project.conf11
-rw-r--r--tests/format/include/junction_options_element/element.bst4
-rw-r--r--tests/format/include/junction_options_element/project.conf1
-rw-r--r--tests/format/include/junction_options_element/subproject/extra_conf.yml7
-rw-r--r--tests/format/include/junction_options_element/subproject/project.conf11
15 files changed, 130 insertions, 0 deletions
diff --git a/tests/format/include.py b/tests/format/include.py
index 36e723ed0..cfbfb66e3 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -261,3 +261,61 @@ def test_include_project_file(cli, datafiles):
result.assert_success()
loaded = _yaml.load_data(result.output)
assert loaded['included'] == 'True'
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_option_from_junction(cli, tmpdir, datafiles):
+ project = os.path.join(str(datafiles), "junction_options")
+
+ generate_junction(
+ tmpdir,
+ os.path.join(project, "subproject"),
+ os.path.join(project, "junction.bst"),
+ store_ref=True,
+ options={"local_option": "set"},
+ )
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
+ result.assert_success()
+ loaded = _yaml.load_data(result.output)
+ assert loaded["is-default"] == 'False'
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_option_from_junction_element(cli, tmpdir, datafiles):
+ project = os.path.join(str(datafiles), "junction_options_element")
+
+ generate_junction(
+ tmpdir,
+ os.path.join(project, "subproject"),
+ os.path.join(project, "junction.bst"),
+ store_ref=True,
+ options={"local_option": "set"},
+ )
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
+ result.assert_success()
+ loaded = _yaml.load_data(result.output)
+ assert loaded["is-default"] == 'False'
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_option_from_deep_junction(cli, tmpdir, datafiles):
+ project = os.path.join(str(datafiles), "junction_options_deep")
+
+ generate_junction(
+ tmpdir,
+ os.path.join(project, "subproject-2"),
+ os.path.join(project, "subproject-1", "junction-2.bst"),
+ store_ref=True,
+ options={"local_option": "set"},
+ )
+
+ generate_junction(
+ tmpdir, os.path.join(project, "subproject-1"), os.path.join(project, "junction-1.bst"), store_ref=True,
+ )
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
+ result.assert_success()
+ loaded = _yaml.load_data(result.output)
+ assert loaded["is-default"] == 'False'
diff --git a/tests/format/include/junction_options/element.bst b/tests/format/include/junction_options/element.bst
new file mode 100644
index 000000000..4d7f70266
--- /dev/null
+++ b/tests/format/include/junction_options/element.bst
@@ -0,0 +1 @@
+kind: manual
diff --git a/tests/format/include/junction_options/project.conf b/tests/format/include/junction_options/project.conf
new file mode 100644
index 000000000..4836c5f8b
--- /dev/null
+++ b/tests/format/include/junction_options/project.conf
@@ -0,0 +1,4 @@
+name: test
+
+(@):
+ - junction.bst:extra_conf.yml
diff --git a/tests/format/include/junction_options/subproject/extra_conf.yml b/tests/format/include/junction_options/subproject/extra_conf.yml
new file mode 100644
index 000000000..1edbeee36
--- /dev/null
+++ b/tests/format/include/junction_options/subproject/extra_conf.yml
@@ -0,0 +1,7 @@
+(?):
+- local_option == 'default':
+ variables:
+ is-default: 'True'
+- local_option == 'set':
+ variables:
+ is-default: 'False'
diff --git a/tests/format/include/junction_options/subproject/project.conf b/tests/format/include/junction_options/subproject/project.conf
new file mode 100644
index 000000000..33ab0c8af
--- /dev/null
+++ b/tests/format/include/junction_options/subproject/project.conf
@@ -0,0 +1,11 @@
+name: test-sub
+
+options:
+ local_option:
+ type: enum
+ description: Testing
+ variable: local_option
+ default: default
+ values:
+ - default
+ - set
diff --git a/tests/format/include/junction_options_deep/element.bst b/tests/format/include/junction_options_deep/element.bst
new file mode 100644
index 000000000..4d7f70266
--- /dev/null
+++ b/tests/format/include/junction_options_deep/element.bst
@@ -0,0 +1 @@
+kind: manual
diff --git a/tests/format/include/junction_options_deep/project.conf b/tests/format/include/junction_options_deep/project.conf
new file mode 100644
index 000000000..2525081ce
--- /dev/null
+++ b/tests/format/include/junction_options_deep/project.conf
@@ -0,0 +1,4 @@
+name: test
+
+(@):
+ - junction-1.bst:extra_conf.yml
diff --git a/tests/format/include/junction_options_deep/subproject-1/extra_conf.yml b/tests/format/include/junction_options_deep/subproject-1/extra_conf.yml
new file mode 100644
index 000000000..faa1a40f7
--- /dev/null
+++ b/tests/format/include/junction_options_deep/subproject-1/extra_conf.yml
@@ -0,0 +1,2 @@
+(@):
+ junction-2.bst:extra_conf.yml
diff --git a/tests/format/include/junction_options_deep/subproject-1/project.conf b/tests/format/include/junction_options_deep/subproject-1/project.conf
new file mode 100644
index 000000000..f0cd28202
--- /dev/null
+++ b/tests/format/include/junction_options_deep/subproject-1/project.conf
@@ -0,0 +1 @@
+name: test-sub-1
diff --git a/tests/format/include/junction_options_deep/subproject-2/extra_conf.yml b/tests/format/include/junction_options_deep/subproject-2/extra_conf.yml
new file mode 100644
index 000000000..1edbeee36
--- /dev/null
+++ b/tests/format/include/junction_options_deep/subproject-2/extra_conf.yml
@@ -0,0 +1,7 @@
+(?):
+- local_option == 'default':
+ variables:
+ is-default: 'True'
+- local_option == 'set':
+ variables:
+ is-default: 'False'
diff --git a/tests/format/include/junction_options_deep/subproject-2/project.conf b/tests/format/include/junction_options_deep/subproject-2/project.conf
new file mode 100644
index 000000000..d44ccd809
--- /dev/null
+++ b/tests/format/include/junction_options_deep/subproject-2/project.conf
@@ -0,0 +1,11 @@
+name: test-sub-2
+
+options:
+ local_option:
+ type: enum
+ description: Testing
+ variable: local_option
+ default: default
+ values:
+ - default
+ - set
diff --git a/tests/format/include/junction_options_element/element.bst b/tests/format/include/junction_options_element/element.bst
new file mode 100644
index 000000000..c815951b6
--- /dev/null
+++ b/tests/format/include/junction_options_element/element.bst
@@ -0,0 +1,4 @@
+kind: manual
+
+(@):
+ - junction.bst:extra_conf.yml
diff --git a/tests/format/include/junction_options_element/project.conf b/tests/format/include/junction_options_element/project.conf
new file mode 100644
index 000000000..b32753625
--- /dev/null
+++ b/tests/format/include/junction_options_element/project.conf
@@ -0,0 +1 @@
+name: test
diff --git a/tests/format/include/junction_options_element/subproject/extra_conf.yml b/tests/format/include/junction_options_element/subproject/extra_conf.yml
new file mode 100644
index 000000000..1edbeee36
--- /dev/null
+++ b/tests/format/include/junction_options_element/subproject/extra_conf.yml
@@ -0,0 +1,7 @@
+(?):
+- local_option == 'default':
+ variables:
+ is-default: 'True'
+- local_option == 'set':
+ variables:
+ is-default: 'False'
diff --git a/tests/format/include/junction_options_element/subproject/project.conf b/tests/format/include/junction_options_element/subproject/project.conf
new file mode 100644
index 000000000..33ab0c8af
--- /dev/null
+++ b/tests/format/include/junction_options_element/subproject/project.conf
@@ -0,0 +1,11 @@
+name: test-sub
+
+options:
+ local_option:
+ type: enum
+ description: Testing
+ variable: local_option
+ default: default
+ values:
+ - default
+ - set