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

juergbi pushed a commit to branch jbilleter/loader
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit dc0a2656d05a10b39cffdf57b9604396a1d08eff
Author: Harry Sarson <[email protected]>
AuthorDate: Wed Aug 13 15:40:08 2025 +0100

    tests/format/junctions.py: Add override-self test for nested-link bug
    
    This commit adds an additional level of nesting to a copy of the
    override-self buildstream test project by a new subproject and moving
    the self-junction into the subproject.
    
    Both the `link.bst` and the `nested-link.bst` elements point to the
    subproject's `target.bst` element but `nested-link.bst` does so via the
    self-junction, hence the "nesting".
    
    Running `bst show --deps none nested-link.bst` in the directory
    `tests/format/junctions/override-self-link` gives the following output:
    
    ```
    20:17:48 --:--:--              main:core activity                  START   
Loading elements
    20:17:48 00:00:00              main:core activity                  FAILURE 
Loading elements
    
    project.conf [line 6 column 2]: Circular reference while searching for 
'subproject.bst:self-junction.bst'
    
        Already searching for 'subproject.bst:self-junction.bst' at: 
nested-link.bst [line 4 column 10]
    ```
---
 tests/format/junctions.py                          | 28 ++++++++++++++++++++++
 tests/format/junctions/override-self-link/link.bst |  4 ++++
 .../junctions/override-self-link/nested-link.bst   |  4 ++++
 .../junctions/override-self-link/project.conf      |  6 +++++
 .../junctions/override-self-link/subproject.bst    |  4 ++++
 .../override-self-link/subproject/alternative.bst  |  4 ++++
 .../override-self-link/subproject/include.yml      |  0
 .../override-self-link/subproject/project.conf     |  6 +++++
 .../subproject/self-junction.bst                   |  9 +++++++
 .../override-self-link/subproject/target.bst       |  4 ++++
 10 files changed, 69 insertions(+)

diff --git a/tests/format/junctions.py b/tests/format/junctions.py
index 458aa3a53..2aaaaede3 100644
--- a/tests/format/junctions.py
+++ b/tests/format/junctions.py
@@ -610,6 +610,34 @@ def test_override_self(cli, datafiles, target, 
expected_result):
     assert result_vars.get_str("animal") == expected_result
 
 
[email protected](DATA_DIR)
[email protected](
+    "target,expected_result",
+    [
+        ("subproject.bst:target.bst", "pony"),
+        ("subproject.bst:self-junction.bst:target.bst", "horsy"),
+        ("link.bst", "pony"),
+        ("nested-link.bst", "horsy"),
+    ],
+    ids=[
+        "direct-target",
+        "override-target",
+        "link-target",
+        "link-override-target",
+    ],
+)
+def test_override_self_link(cli, datafiles, target, expected_result):
+    project = os.path.join(str(datafiles), "override-self-link")
+    result = cli.run(
+        project=project,
+        silent=True,
+        args=["show", "--deps", "none", "--format", "%{vars}", target],
+    )
+    result.assert_success()
+    result_vars = _yaml.load_data(result.output)
+    assert result_vars.get_str("animal") == expected_result
+
+
 #
 # Test conflicting junction scenarios
 #
diff --git a/tests/format/junctions/override-self-link/link.bst 
b/tests/format/junctions/override-self-link/link.bst
new file mode 100644
index 000000000..3da195d89
--- /dev/null
+++ b/tests/format/junctions/override-self-link/link.bst
@@ -0,0 +1,4 @@
+kind: link
+
+config:
+  target: subproject.bst:target.bst
diff --git a/tests/format/junctions/override-self-link/nested-link.bst 
b/tests/format/junctions/override-self-link/nested-link.bst
new file mode 100644
index 000000000..fa2b2b571
--- /dev/null
+++ b/tests/format/junctions/override-self-link/nested-link.bst
@@ -0,0 +1,4 @@
+kind: link
+
+config:
+  target: subproject.bst:self-junction.bst:target.bst
diff --git a/tests/format/junctions/override-self-link/project.conf 
b/tests/format/junctions/override-self-link/project.conf
new file mode 100644
index 000000000..ed7370c4f
--- /dev/null
+++ b/tests/format/junctions/override-self-link/project.conf
@@ -0,0 +1,6 @@
+name: test
+min-version: 2.0
+
+
+(@):
+- subproject.bst:self-junction.bst:include.yml
diff --git a/tests/format/junctions/override-self-link/subproject.bst 
b/tests/format/junctions/override-self-link/subproject.bst
new file mode 100644
index 000000000..c88189cb0
--- /dev/null
+++ b/tests/format/junctions/override-self-link/subproject.bst
@@ -0,0 +1,4 @@
+kind: junction
+sources:
+- kind: local
+  path: subproject
diff --git 
a/tests/format/junctions/override-self-link/subproject/alternative.bst 
b/tests/format/junctions/override-self-link/subproject/alternative.bst
new file mode 100644
index 000000000..11dbb8116
--- /dev/null
+++ b/tests/format/junctions/override-self-link/subproject/alternative.bst
@@ -0,0 +1,4 @@
+kind: stack
+
+variables:
+  animal: horsy
diff --git a/tests/format/junctions/override-self-link/subproject/include.yml 
b/tests/format/junctions/override-self-link/subproject/include.yml
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/format/junctions/override-self-link/subproject/project.conf 
b/tests/format/junctions/override-self-link/subproject/project.conf
new file mode 100644
index 000000000..649bb6d3e
--- /dev/null
+++ b/tests/format/junctions/override-self-link/subproject/project.conf
@@ -0,0 +1,6 @@
+name: subproject
+min-version: 2.0
+
+junctions:
+  internal:
+  - self-junction.bst
diff --git 
a/tests/format/junctions/override-self-link/subproject/self-junction.bst 
b/tests/format/junctions/override-self-link/subproject/self-junction.bst
new file mode 100644
index 000000000..52ea670a0
--- /dev/null
+++ b/tests/format/junctions/override-self-link/subproject/self-junction.bst
@@ -0,0 +1,9 @@
+kind: junction
+sources:
+- kind: local
+  path: .
+
+
+config:
+  overrides:
+    target.bst: alternative.bst
diff --git a/tests/format/junctions/override-self-link/subproject/target.bst 
b/tests/format/junctions/override-self-link/subproject/target.bst
new file mode 100644
index 000000000..489d7b0c8
--- /dev/null
+++ b/tests/format/junctions/override-self-link/subproject/target.bst
@@ -0,0 +1,4 @@
+kind: stack
+
+variables:
+  animal: pony

Reply via email to