You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ju...@apache.org on 2022/06/12 10:45:37 UTC
[buildstream] branch juerg/subproject-ref-storage created (now 079dbfdb3)
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a change to branch juerg/subproject-ref-storage
in repository https://gitbox.apache.org/repos/asf/buildstream.git
at 079dbfdb3 tests/format/junctions.py: Test project.refs in subproject
This branch includes the following new commits:
new 1ddb96add source.py: Don't ignore project.refs of subprojects
new 079dbfdb3 tests/format/junctions.py: Test project.refs in subproject
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] 02/02: tests/format/junctions.py: Test project.refs in subproject
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch juerg/subproject-ref-storage
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 079dbfdb3f5194e90863aa3162b07065285a6e60
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Sun Jun 12 12:33:01 2022 +0200
tests/format/junctions.py: Test project.refs in subproject
---
tests/format/junctions.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/tests/format/junctions.py b/tests/format/junctions.py
index 929832635..d17d47f5e 100644
--- a/tests/format/junctions.py
+++ b/tests/format/junctions.py
@@ -2,6 +2,7 @@
# pylint: disable=redefined-outer-name
import os
+import shutil
import pytest
@@ -9,6 +10,7 @@ from buildstream import _yaml
from buildstream.exceptions import ErrorDomain, LoadErrorReason
from buildstream._testing import cli # pylint: disable=unused-import
from buildstream._testing import create_repo
+from tests.testutils import generate_junction
DATA_DIR = os.path.join(
@@ -119,6 +121,51 @@ def test_nested(cli, tmpdir, datafiles, target, expected):
assert os.path.exists(os.path.join(checkoutdir, filename))
+#
+# Test successful builds of deeply nested targets with both the top-level project
+# and a subproject configured to use `project.refs`
+#
+@pytest.mark.datafiles(DATA_DIR)
+@pytest.mark.parametrize(
+ "target,expected",
+ [
+ ("target.bst", ["sub.txt", "subsub.txt"]),
+ ("deeptarget.bst", ["sub.txt", "subsub.txt", "subsubsub.txt"]),
+ ],
+ ids=["simple", "deep"],
+)
+def test_nested_ref_storage(cli, tmpdir, datafiles, target, expected):
+ project = os.path.join(str(datafiles), "nested")
+ subproject = os.path.join(project, "subproject")
+ subsubproject = os.path.join(subproject, "subsubproject")
+
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
+
+ # Configure both the top-level project and the subproject to use project.refs / junction.refs
+ update_project(project, {"ref-storage": "project.refs"})
+ update_project(subproject, {"ref-storage": "project.refs"})
+
+ # Move the subsubproject from a local directory to a repo to test `junction.refs` in the subproject
+ subsubref = generate_junction(
+ tmpdir, subsubproject, os.path.join(subproject, "subsubproject.bst"), store_ref=False
+ )
+ shutil.rmtree(subsubproject)
+
+ # Store ref to the subsubproject repo in the subproject's `junction.refs`
+ project_refs = {"projects": {"subtest": {"subsubproject.bst": [{"ref": subsubref}]}}}
+ _yaml.roundtrip_dump(project_refs, os.path.join(subproject, "junction.refs"))
+
+ # Build, checkout
+ result = cli.run(project=project, args=["build", target])
+ result.assert_success()
+ result = cli.run(project=project, args=["artifact", "checkout", target, "--directory", checkoutdir])
+ result.assert_success()
+
+ # Check that the checkout contains the expected files from all subprojects
+ for filename in expected:
+ assert os.path.exists(os.path.join(checkoutdir, filename))
+
+
#
# Test missing elements/junctions in subprojects
#
[buildstream] 01/02: source.py: Don't ignore project.refs of subprojects
Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch juerg/subproject-ref-storage
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 1ddb96add5397930f5085b532cba4121d1b397bc
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Sun Jun 12 12:32:05 2022 +0200
source.py: Don't ignore project.refs of subprojects
---
src/buildstream/source.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/buildstream/source.py b/src/buildstream/source.py
index ad4c37d2e..e35d734a1 100644
--- a/src/buildstream/source.py
+++ b/src/buildstream/source.py
@@ -953,13 +953,14 @@ class Source(Plugin):
ref_node = refs.lookup_ref(project.name, element_name, element_idx)
if ref_node is not None:
do_load_ref(ref_node)
+ return redundant_ref
# If the project itself uses project.refs, clear the ref which
# was already loaded via Source.configure(), as this would
# violate the rule of refs being either in project.refs or in
# the elements themselves.
#
- elif project.ref_storage == ProjectRefStorage.PROJECT_REFS:
+ if project.ref_storage == ProjectRefStorage.PROJECT_REFS:
# First warn if there is a ref already loaded, and reset it
redundant_ref = self.get_ref() # pylint: disable=assignment-from-no-return