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 2026/05/01 16:35:09 UTC
(buildstream) 03/03: tests/sources/source_provenance_attributes.py: Test junction provenance
This is an automated email from the ASF dual-hosted git repository.
juergbi pushed a commit to branch jbilleter/junction-provenance
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit efba6297786c96f81a7e32b24c3518eb958fd512
Author: Jürg Billeter <j...@bitron.ch>
AuthorDate: Sun Apr 26 17:02:52 2026 +0200
tests/sources/source_provenance_attributes.py: Test junction provenance
Junctions may be loaded before a project is fully loaded, which means
that the source provenance attribute project configuration may not be
available yet.
---
tests/sources/source_provenance_attributes.py | 21 ++++++++++++---------
.../elements/junction_a.bst | 7 +++++++
.../elements/junction_b.bst | 7 +++++++
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/tests/sources/source_provenance_attributes.py b/tests/sources/source_provenance_attributes.py
index 04c48ba97..b65d7cb4b 100644
--- a/tests/sources/source_provenance_attributes.py
+++ b/tests/sources/source_provenance_attributes.py
@@ -54,7 +54,8 @@ def test_source_provenance_disallow_top_level(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
-def test_source_provenance_no_defined_attributes(cli, datafiles):
+@pytest.mark.parametrize("element", ["target", "junction"])
+def test_source_provenance_no_defined_attributes(cli, datafiles, element):
project = str(datafiles)
# Set the project_dir alias in project.conf to the path to the tested project
@@ -68,21 +69,22 @@ def test_source_provenance_no_defined_attributes(cli, datafiles):
# Make sure a non-default attribute fails
result = cli.run(
project=project,
- args=["show", "--format", "%{source-info}", "target_a.bst"],
+ args=["show", "--format", "%{source-info}", f"{element}_a.bst"],
)
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNDEFINED_SOURCE_PROVENANCE_ATTRIBUTE)
# Make sure a default attribute fails
result = cli.run(
project=project,
- args=["show", "--format", "%{source-info}", "target_b.bst"],
+ args=["show", "--format", "%{source-info}", f"{element}_b.bst"],
)
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNDEFINED_SOURCE_PROVENANCE_ATTRIBUTE)
# Test that no defined source provenance attributes blocks all source provenance data
@pytest.mark.datafiles(DATA_DIR)
-def test_source_provenance_default_attributes(cli, datafiles):
+@pytest.mark.parametrize("element", ["target", "junction"])
+def test_source_provenance_default_attributes(cli, datafiles, element):
project = str(datafiles)
# Set the project_dir alias in project.conf to the path to the tested project
@@ -99,7 +101,7 @@ def test_source_provenance_default_attributes(cli, datafiles):
# Make sure defined attributes are available
result = cli.run(
project=project,
- args=["show", "--format", "%{source-info}", "target_b.bst"],
+ args=["show", "--format", "%{source-info}", f"{element}_b.bst"],
)
result.assert_success()
@@ -113,14 +115,15 @@ def test_source_provenance_default_attributes(cli, datafiles):
# Make sure undefined attributes fail
result = cli.run(
project=project,
- args=["show", "--format", "%{source-info}", "target_a.bst"],
+ args=["show", "--format", "%{source-info}", f"{element}_a.bst"],
)
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNDEFINED_SOURCE_PROVENANCE_ATTRIBUTE)
# Test that no defined source provenance attributes blocks all source provenance data
@pytest.mark.datafiles(DATA_DIR)
-def test_source_provenance_project_defined_attributes(cli, datafiles):
+@pytest.mark.parametrize("element", ["target", "junction"])
+def test_source_provenance_project_defined_attributes(cli, datafiles, element):
project = str(datafiles)
# Set the project_dir alias in project.conf to the path to the tested project
@@ -139,7 +142,7 @@ def test_source_provenance_project_defined_attributes(cli, datafiles):
# Make sure defined attributes are available
result = cli.run(
project=project,
- args=["show", "--format", "%{source-info}", "target_a.bst"],
+ args=["show", "--format", "%{source-info}", f"{element}_a.bst"],
)
result.assert_success()
@@ -153,6 +156,6 @@ def test_source_provenance_project_defined_attributes(cli, datafiles):
# Make sure undefined attributes fail
result = cli.run(
project=project,
- args=["show", "--format", "%{source-info}", "target_b.bst"],
+ args=["show", "--format", "%{source-info}", f"{element}_b.bst"],
)
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNDEFINED_SOURCE_PROVENANCE_ATTRIBUTE)
diff --git a/tests/sources/source_provenance_attributes/elements/junction_a.bst b/tests/sources/source_provenance_attributes/elements/junction_a.bst
new file mode 100644
index 000000000..364acebad
--- /dev/null
+++ b/tests/sources/source_provenance_attributes/elements/junction_a.bst
@@ -0,0 +1,7 @@
+kind: junction
+
+sources:
+- kind: local
+ path: .
+ provenance:
+ originator: bar
diff --git a/tests/sources/source_provenance_attributes/elements/junction_b.bst b/tests/sources/source_provenance_attributes/elements/junction_b.bst
new file mode 100644
index 000000000..e4d68feb9
--- /dev/null
+++ b/tests/sources/source_provenance_attributes/elements/junction_b.bst
@@ -0,0 +1,7 @@
+kind: junction
+
+sources:
+- kind: local
+ path: .
+ provenance:
+ homepage: foo