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 2025/11/21 14:20:07 UTC
(buildstream) 03/03: tests/format/link.py: Add test for multiple links with the same target
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch jbilleter/links
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit 78c3e47184071f8b9489062e13b176c37e4efb34
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Fri Nov 21 10:28:02 2025 +0100
tests/format/link.py: Add test for multiple links with the same target
This is a regression test for #2002.
---
tests/format/link.py | 20 ++++++++++++++++++++
.../elements/hello-link-1.bst | 4 ++++
.../elements/hello-link-2.bst | 4 ++++
.../multiple-links-same-target/elements/hello.bst | 5 +++++
.../multiple-links-same-target/elements/target.bst | 5 +++++
.../link/multiple-links-same-target/files/hello.txt | 1 +
.../link/multiple-links-same-target/project.conf | 4 ++++
7 files changed, 43 insertions(+)
diff --git a/tests/format/link.py b/tests/format/link.py
index fee6de37b..ee8136bca 100644
--- a/tests/format/link.py
+++ b/tests/format/link.py
@@ -198,3 +198,23 @@ def test_cross_link_junction_include(cli, tmpdir, datafiles):
# Read back some of our project defaults from the env
variables = _yaml.load_data(result.output)
assert variables.get_str("test") == "the test"
+
+
+#
+# Test two links to the same element, both links are dependencies of the build target.
+#
+@pytest.mark.datafiles(DATA_DIR)
+def test_multiple_links_same_target(cli, tmpdir, datafiles):
+ project = os.path.join(str(datafiles), "multiple-links-same-target")
+ checkoutdir = os.path.join(str(tmpdir), "checkout")
+
+ target = "target.bst"
+
+ # 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 sub-sub-project
+ assert os.path.exists(os.path.join(checkoutdir, "hello.txt"))
diff --git a/tests/format/link/multiple-links-same-target/elements/hello-link-1.bst b/tests/format/link/multiple-links-same-target/elements/hello-link-1.bst
new file mode 100644
index 000000000..83b0fbe46
--- /dev/null
+++ b/tests/format/link/multiple-links-same-target/elements/hello-link-1.bst
@@ -0,0 +1,4 @@
+kind: link
+
+config:
+ target: hello.bst
diff --git a/tests/format/link/multiple-links-same-target/elements/hello-link-2.bst b/tests/format/link/multiple-links-same-target/elements/hello-link-2.bst
new file mode 100644
index 000000000..83b0fbe46
--- /dev/null
+++ b/tests/format/link/multiple-links-same-target/elements/hello-link-2.bst
@@ -0,0 +1,4 @@
+kind: link
+
+config:
+ target: hello.bst
diff --git a/tests/format/link/multiple-links-same-target/elements/hello.bst b/tests/format/link/multiple-links-same-target/elements/hello.bst
new file mode 100644
index 000000000..a04a856cd
--- /dev/null
+++ b/tests/format/link/multiple-links-same-target/elements/hello.bst
@@ -0,0 +1,5 @@
+kind: import
+
+sources:
+- kind: local
+ path: files/hello.txt
diff --git a/tests/format/link/multiple-links-same-target/elements/target.bst b/tests/format/link/multiple-links-same-target/elements/target.bst
new file mode 100644
index 000000000..a547ef44b
--- /dev/null
+++ b/tests/format/link/multiple-links-same-target/elements/target.bst
@@ -0,0 +1,5 @@
+kind: stack
+
+depends:
+- hello-link-1.bst
+- hello-link-2.bst
diff --git a/tests/format/link/multiple-links-same-target/files/hello.txt b/tests/format/link/multiple-links-same-target/files/hello.txt
new file mode 100644
index 000000000..ce0136250
--- /dev/null
+++ b/tests/format/link/multiple-links-same-target/files/hello.txt
@@ -0,0 +1 @@
+hello
diff --git a/tests/format/link/multiple-links-same-target/project.conf b/tests/format/link/multiple-links-same-target/project.conf
new file mode 100644
index 000000000..12a1b2551
--- /dev/null
+++ b/tests/format/link/multiple-links-same-target/project.conf
@@ -0,0 +1,4 @@
+name: multiple-links-single-target
+min-version: 2.0
+
+element-path: elements