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/22 05:30:12 UTC

[buildstream] branch tristan/resolve-conditionals-project-root updated (574db6dd0 -> fcf78edfe)

This is an automated email from the ASF dual-hosted git repository.

tvb pushed a change to branch tristan/resolve-conditionals-project-root
in repository https://gitbox.apache.org/repos/asf/buildstream.git


 discard 574db6dd0 tests/format/optionprojectroot.py: Test option resolution in element overrides
 discard dcc689890 tests/format/optionprojectroot.py: Test project root conditional resolution
     new 0d4d89b44 tests/format/optionprojectroot.py: Test project root conditional resolution
     new fcf78edfe tests/format/optionprojectroot.py: Test option resolution in element overrides

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (574db6dd0)
            \
             N -- N -- N   refs/heads/tristan/resolve-conditionals-project-root (fcf78edfe)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 tests/format/optionprojectroot.py | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)


[buildstream] 01/02: tests/format/optionprojectroot.py: Test project root conditional resolution

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/resolve-conditionals-project-root
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 0d4d89b44eda9b79f6e374c41eff71f3ed213524
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Fri Jul 22 14:17:42 2022 +0900

    tests/format/optionprojectroot.py: Test project root conditional resolution
---
 tests/format/option-project-root/element.bst  |  1 +
 tests/format/option-project-root/project.conf | 19 ++++++++++++++++++
 tests/format/optionprojectroot.py             | 28 +++++++++++++++++++++++++++
 3 files changed, 48 insertions(+)

diff --git a/tests/format/option-project-root/element.bst b/tests/format/option-project-root/element.bst
new file mode 100644
index 000000000..4d7f70266
--- /dev/null
+++ b/tests/format/option-project-root/element.bst
@@ -0,0 +1 @@
+kind: manual
diff --git a/tests/format/option-project-root/project.conf b/tests/format/option-project-root/project.conf
new file mode 100644
index 000000000..eb254bc2c
--- /dev/null
+++ b/tests/format/option-project-root/project.conf
@@ -0,0 +1,19 @@
+name: test
+min-version: 2.0
+
+options:
+  animal:
+    type: enum
+    description: The kind of animal
+    values:
+    - pony
+    - horsy
+    default: pony
+
+(?):
+- animal == "pony":
+    variables:
+      result: "a pony"
+- animal == "horsy":
+    variables:
+      result: "a horsy"
diff --git a/tests/format/optionprojectroot.py b/tests/format/optionprojectroot.py
new file mode 100644
index 000000000..5ea3508ab
--- /dev/null
+++ b/tests/format/optionprojectroot.py
@@ -0,0 +1,28 @@
+# Pylint doesn't play well with fixtures and dependency injection from pytest
+# pylint: disable=redefined-outer-name
+
+import os
+import pytest
+from buildstream import _yaml
+from buildstream.exceptions import ErrorDomain, LoadErrorReason
+from buildstream._testing.runcli import cli  # pylint: disable=unused-import
+
+# Project directory
+DATA_DIR = os.path.dirname(os.path.realpath(__file__))
+
+
+#
+# Test that project option conditionals can be resolved in the project root
+#
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("value,expected", [("pony", "a pony"), ("horsy", "a horsy")], ids=["pony", "horsy"])
+def test_resolve_project_root_conditional(cli, datafiles, value, expected):
+    project = os.path.join(datafiles.dirname, datafiles.basename, "option-project-root")
+    result = cli.run(
+        project=project,
+        silent=True,
+        args=["--option", "animal", value, "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+    )
+    result.assert_success()
+    loaded = _yaml.load_data(result.output)
+    assert loaded.get_str("result") == expected


[buildstream] 02/02: tests/format/optionprojectroot.py: Test option resolution in element overrides

Posted by tv...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tvb pushed a commit to branch tristan/resolve-conditionals-project-root
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit fcf78edfe6785df4370cdb26cbdc6115ebce5b95
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Fri Jul 22 14:27:31 2022 +0900

    tests/format/optionprojectroot.py: Test option resolution in element overrides
    
    This already appears to be working fine, but let's just add another test
    to be sure.
---
 tests/format/option-element-override/element.bst  |  1 +
 tests/format/option-element-override/project.conf | 24 +++++++++++++++++++++++
 tests/format/optionprojectroot.py                 | 17 ++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/tests/format/option-element-override/element.bst b/tests/format/option-element-override/element.bst
new file mode 100644
index 000000000..4d7f70266
--- /dev/null
+++ b/tests/format/option-element-override/element.bst
@@ -0,0 +1 @@
+kind: manual
diff --git a/tests/format/option-element-override/project.conf b/tests/format/option-element-override/project.conf
new file mode 100644
index 000000000..63df718a6
--- /dev/null
+++ b/tests/format/option-element-override/project.conf
@@ -0,0 +1,24 @@
+name: test
+min-version: 2.0
+
+options:
+  animal:
+    type: enum
+    description: The kind of animal
+    values:
+    - pony
+    - horsy
+    default: pony
+
+variables:
+  result: "a sloppy joe"
+
+elements:
+  manual:
+    (?):
+    - animal == "pony":
+        variables:
+          result: "a pony"
+    - animal == "horsy":
+        variables:
+          result: "a horsy"
diff --git a/tests/format/optionprojectroot.py b/tests/format/optionprojectroot.py
index 5ea3508ab..44eb2abc8 100644
--- a/tests/format/optionprojectroot.py
+++ b/tests/format/optionprojectroot.py
@@ -26,3 +26,20 @@ def test_resolve_project_root_conditional(cli, datafiles, value, expected):
     result.assert_success()
     loaded = _yaml.load_data(result.output)
     assert loaded.get_str("result") == expected
+
+
+#
+# Test that project option conditionals can be resolved in element overrides
+#
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize("value,expected", [("pony", "a pony"), ("horsy", "a horsy")], ids=["pony", "horsy"])
+def test_resolve_element_override_conditional(cli, datafiles, value, expected):
+    project = os.path.join(datafiles.dirname, datafiles.basename, "option-element-override")
+    result = cli.run(
+        project=project,
+        silent=True,
+        args=["--option", "animal", value, "show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+    )
+    result.assert_success()
+    loaded = _yaml.load_data(result.output)
+    assert loaded.get_str("result") == expected