You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by tv...@apache.org on 2022/07/25 09:00:35 UTC
[buildstream] 02/02: tests/format/junctions.py: Test complex cross junction include scenario
This is an automated email from the ASF dual-hosted git repository.
tvb pushed a commit to branch tristan/fix-load-cross-project-element
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 3412f3720d1f6e3cd02f225c2c76f86f94287328
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Mon Jul 25 16:15:06 2022 +0900
tests/format/junctions.py: Test complex cross junction include scenario
In this scenario, loading a file directly across a junction, without using
a depending toplevel project element, produces stack traces.
---
tests/format/junctions.py | 40 ++++++++++++++++++++++
.../format/junctions/include-complex/project.conf | 15 ++++++++
.../junctions/include-complex/subproject.bst | 8 +++++
.../include-complex/subproject/project.conf | 11 ++++++
.../include-complex/subproject/target.bst | 4 +++
5 files changed, 78 insertions(+)
diff --git a/tests/format/junctions.py b/tests/format/junctions.py
index c9615397c..6f0a5d1de 100644
--- a/tests/format/junctions.py
+++ b/tests/format/junctions.py
@@ -880,3 +880,43 @@ def test_include_vars_optional(cli, datafiles, use_species, expected_result):
result.assert_success()
result_vars = _yaml.load_data(result.output)
assert result_vars.get_str("resolved") == expected_result
+
+
+# This test verifies that project option conditional statements made
+# in an include file are resolved in the context of the project where
+# the include file originates.
+#
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize(
+ "target",
+ ["target.bst", "subproject.bst:target.bst"],
+ ids=["toplevel-target", "subproject-target"],
+)
+@pytest.mark.parametrize(
+ "animal,expected_result",
+ [
+ ("pony", "target pony"),
+ ("horsy", "target horsy"),
+ ],
+ ids=["branch1", "branch2"],
+)
+def test_include_vars_cross_junction_element(cli, datafiles, target, animal, expected_result):
+ project = os.path.join(str(datafiles), "include-complex")
+ result = cli.run(
+ project=project,
+ silent=True,
+ args=[
+ "--option",
+ "animal",
+ animal,
+ "show",
+ "--deps",
+ "none",
+ "--format",
+ "%{vars}",
+ target,
+ ],
+ )
+ result.assert_success()
+ result_vars = _yaml.load_data(result.output)
+ assert result_vars.get_str("target_animal_variable") == expected_result
diff --git a/tests/format/junctions/include-complex/project.conf b/tests/format/junctions/include-complex/project.conf
new file mode 100644
index 000000000..eb7f3c746
--- /dev/null
+++ b/tests/format/junctions/include-complex/project.conf
@@ -0,0 +1,15 @@
+name: test
+min-version: 2.0
+
+(@):
+- subproject.bst:include.yml
+
+options:
+ animal:
+ type: enum
+ description: the animal
+ values:
+ - pony
+ - horsy
+ default: pony
+ variable: animal
diff --git a/tests/format/junctions/include-complex/subproject.bst b/tests/format/junctions/include-complex/subproject.bst
new file mode 100644
index 000000000..daaea3091
--- /dev/null
+++ b/tests/format/junctions/include-complex/subproject.bst
@@ -0,0 +1,8 @@
+kind: junction
+sources:
+- kind: local
+ path: subproject
+
+config:
+ options:
+ target_animal: '%{animal}'
diff --git a/tests/format/junctions/include-complex/subproject/project.conf b/tests/format/junctions/include-complex/subproject/project.conf
new file mode 100644
index 000000000..ad8a3b3de
--- /dev/null
+++ b/tests/format/junctions/include-complex/subproject/project.conf
@@ -0,0 +1,11 @@
+name: subtest
+min-version: 2.0
+
+options:
+ target_animal:
+ type: enum
+ description: the target animal
+ values:
+ - pony
+ - horsy
+ default: pony
diff --git a/tests/format/junctions/include-complex/subproject/target.bst b/tests/format/junctions/include-complex/subproject/target.bst
new file mode 100644
index 000000000..9349a1854
--- /dev/null
+++ b/tests/format/junctions/include-complex/subproject/target.bst
@@ -0,0 +1,4 @@
+kind: stack
+
+(@):
+- include.yml