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 09:50:03 UTC

[buildstream] branch tristan/fix-cross-junction-plugins created (now 5da8473b9)

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

tvb pushed a change to branch tristan/fix-cross-junction-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git


      at 5da8473b9 tests/plugin/loading.py: Regression test for complex cross junction scenario

This branch includes the following new commits:

     new 71bf46255 _pluginfactory/pluginoriginjunction.py: Don't force load projects
     new 5da8473b9 tests/plugin/loading.py: Regression test for complex cross junction scenario

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.



[buildstream] 01/02: _pluginfactory/pluginoriginjunction.py: Don't force load projects

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

tvb pushed a commit to branch tristan/fix-cross-junction-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 71bf462551068db7563cfc634741d0756577bfaf
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Fri Jul 22 18:44:49 2022 +0900

    _pluginfactory/pluginoriginjunction.py: Don't force load projects
    
    Cross junction plugin loading must not require completely resolving projects,
    as this will impede the functionality of cross junction includes.
    
    Fixes #1686
---
 src/buildstream/_pluginfactory/pluginoriginjunction.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/buildstream/_pluginfactory/pluginoriginjunction.py b/src/buildstream/_pluginfactory/pluginoriginjunction.py
index 724bd1f40..cf0205c1c 100644
--- a/src/buildstream/_pluginfactory/pluginoriginjunction.py
+++ b/src/buildstream/_pluginfactory/pluginoriginjunction.py
@@ -36,7 +36,6 @@ class PluginOriginJunction(PluginOrigin):
         #
         loader = self.project.loader.get_loader(self._junction, self.provenance_node)
         project = loader.project
-        project.ensure_fully_loaded()
 
         # Now get the appropriate PluginFactory object
         #


[buildstream] 02/02: tests/plugin/loading.py: Regression test for complex cross junction scenario

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

tvb pushed a commit to branch tristan/fix-cross-junction-plugins
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 5da8473b98b059d59185cbc8f8a3214f5a2ca464
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Fri Jul 22 18:46:18 2022 +0900

    tests/plugin/loading.py: Regression test for complex cross junction scenario
    
    This sets up a complex test scenario which provokes the junction
    plugin origin to prematurely resolve projects, triggering issues like #1686.
---
 tests/plugins/junction-with-junction/element.bst   |  1 +
 tests/plugins/junction-with-junction/project.conf  | 11 ++++
 .../junction-with-junction/subproject/project.conf |  2 +
 .../subproject/variables.yml                       |  4 ++
 tests/plugins/loading.py                           | 73 ++++++++++++++++++++++
 tests/plugins/sample-plugins/project.conf          | 15 +++++
 6 files changed, 106 insertions(+)

diff --git a/tests/plugins/junction-with-junction/element.bst b/tests/plugins/junction-with-junction/element.bst
new file mode 100644
index 000000000..4d7f70266
--- /dev/null
+++ b/tests/plugins/junction-with-junction/element.bst
@@ -0,0 +1 @@
+kind: manual
diff --git a/tests/plugins/junction-with-junction/project.conf b/tests/plugins/junction-with-junction/project.conf
new file mode 100644
index 000000000..b64a6b1e7
--- /dev/null
+++ b/tests/plugins/junction-with-junction/project.conf
@@ -0,0 +1,11 @@
+name: test
+min-version: 2.0
+
+plugins:
+- origin: junction
+  junction: sample-plugins.bst
+  sources:
+  - git
+
+(@):
+- subproject.bst:variables.yml
diff --git a/tests/plugins/junction-with-junction/subproject/project.conf b/tests/plugins/junction-with-junction/subproject/project.conf
new file mode 100644
index 000000000..7d535b650
--- /dev/null
+++ b/tests/plugins/junction-with-junction/subproject/project.conf
@@ -0,0 +1,2 @@
+name: subproject-test
+min-version: 2.0
diff --git a/tests/plugins/junction-with-junction/subproject/variables.yml b/tests/plugins/junction-with-junction/subproject/variables.yml
new file mode 100644
index 000000000..c5ade0f85
--- /dev/null
+++ b/tests/plugins/junction-with-junction/subproject/variables.yml
@@ -0,0 +1,4 @@
+
+
+variables:
+  animal: pony
diff --git a/tests/plugins/loading.py b/tests/plugins/loading.py
index 2863133dd..b85dbd29b 100644
--- a/tests/plugins/loading.py
+++ b/tests/plugins/loading.py
@@ -12,8 +12,10 @@ import pytest
 
 from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream._testing import cli  # pylint: disable=unused-import
+from buildstream._testing import create_repo
 from buildstream import _yaml
 
+from tests.testutils.repo.git import Git
 from tests.testutils.site import pip_sample_packages  # pylint: disable=unused-import
 from tests.testutils.site import SAMPLE_PACKAGES_SKIP_REASON
 
@@ -823,3 +825,74 @@ def test_junction_invalid_full_path(cli, datafiles, plugin_type, provenance):
     result = cli.run(project=project, args=["show", "element.bst"])
     result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
     assert provenance in result.stderr
+
+
+# Test scenario for junction plugin origins
+# =========================================
+#
+# This is a regression test which ensures that cross junction includes
+# at the project.conf level continues to work even in conjunction with
+# complex cross junction plugin loading scenarios.
+#
+#         main project
+#         /           \
+#        |             |
+#  junction (tar)      |
+#        |             | include a file across this junction
+#        |             |
+#        /             |
+#  git plugin           \
+#                        \
+#                  junction (git)
+#                         |
+#                         |
+#                     subproject
+#
+#
+# `bst source track subproject.bst`
+#
+#
+JUNCTION_DATA_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)))
+
+
+@pytest.mark.datafiles(JUNCTION_DATA_DIR)
+def test_load_junction_via_junctioned_plugin(cli, datafiles, tmpdir):
+    sample_plugins_dir = os.path.join(str(datafiles), "sample-plugins")
+    project = os.path.join(str(datafiles), "junction-with-junction")
+    subproject = os.path.join(str(datafiles), "junction-with-junction", "subproject")
+
+    # Create a tar repo containing the sample plugins
+    #
+    repo = create_repo("tar", str(tmpdir))
+    ref = repo.create(sample_plugins_dir)
+
+    # Generate the junction to the sample plugins
+    #
+    element = {"kind": "junction", "sources": [repo.source_config(ref=ref)]}
+    _yaml.roundtrip_dump(element, os.path.join(project, "sample-plugins.bst"))
+
+    # Create a git repo containing the subproject
+    #
+    subproject_repo = Git(str(tmpdir))
+    subproject_repo.create(subproject)
+
+    # Generate the subproject junction pointing to the git repo with the subproject
+    #
+    element = {"kind": "junction", "sources": [subproject_repo.source_config()]}
+    _yaml.roundtrip_dump(element, os.path.join(project, "subproject.bst"))
+
+    # Track the subproject
+    #
+    result = cli.run(project=project, args=["source", "track", "subproject.bst"])
+    result.assert_success()
+
+    # Check the included variable resolves in the element
+    #
+    result = cli.run(
+        project=project,
+        silent=True,
+        args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"],
+    )
+    result.assert_success()
+    loaded = _yaml.load_data(result.output)
+    assert loaded.get_str("animal") == "pony"
diff --git a/tests/plugins/sample-plugins/project.conf b/tests/plugins/sample-plugins/project.conf
new file mode 100644
index 000000000..60fd37224
--- /dev/null
+++ b/tests/plugins/sample-plugins/project.conf
@@ -0,0 +1,15 @@
+name: sample-plugins
+min-version: 2.0
+
+plugins:
+- origin: local
+  path: src/sample_plugins/elements
+  elements:
+  - autotools
+  - sample
+
+- origin: local
+  path: src/sample_plugins/sources
+  sources:
+  - git
+  - sample