summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2020-05-28 10:20:01 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2020-05-29 10:55:26 +0000
commitf604ad92cb61109b264b45d15dbe7d2c6aac6bdf (patch)
treef252a17afabb7d0a25df28037579ba187cf121c5 /tests
parent976439c2be5a457f28c2f291f8823d711f09d2d0 (diff)
downloadbuildstream-f604ad92cb61109b264b45d15dbe7d2c6aac6bdf.tar.gz
element.py: Always expand public data's variables
This fixes a bug introduced by d7d18c1a2e454c507afd9e1d3f1358639dd43871, where public data integration commands and others would never get their data expanded and would thus fail to run. The previous however revelead a previous bug, where variables values in public data of elements would not be part of the cache key of an element or it's reverse dependencies, and thus, on variable change, rebuilds would not happen when they would have been needed. This ensures that all the public data is always resolved and part of the element's cache key. This however will bring a rebuild of an element whenever its integration commands variables change, which is simpler to handle than to try to push that responsibility on reverse dependencies, since public data can contain plugin-defined values.
Diffstat (limited to 'tests')
-rw-r--r--tests/format/variables.py21
-rw-r--r--tests/format/variables/public_data_variables/project.conf5
-rw-r--r--tests/format/variables/public_data_variables/public.bst11
-rw-r--r--tests/format/variables/public_data_variables/public_unresolved.bst9
4 files changed, 46 insertions, 0 deletions
diff --git a/tests/format/variables.py b/tests/format/variables.py
index 5f07067f3..616dc20c1 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -138,3 +138,24 @@ def test_variables_are_resolved_in_elements_context(cli, datafiles):
["one.bst"],
["two.bst"],
)
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "public_data_variables"))
+def test_variables_are_resolved_in_public_section(cli, datafiles):
+ project = str(datafiles)
+
+ result = cli.run(project=project, args=["show", "--format", "%{public}", "public.bst"])
+ result.assert_success()
+
+ output = _yaml.load_data(result.output).strip_node_info()
+ expected = {"integration-commands": ["echo expanded"], "test": "expanded"}
+
+ assert {k: v for k, v in output.items() if k in expected} == expected
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, "public_data_variables"))
+def test_variables_resolving_errors_in_public_section(cli, datafiles):
+ project = str(datafiles)
+
+ result = cli.run(project=project, args=["show", "--format", "%{public}", "public_unresolved.bst"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNRESOLVED_VARIABLE)
diff --git a/tests/format/variables/public_data_variables/project.conf b/tests/format/variables/public_data_variables/project.conf
new file mode 100644
index 000000000..ab47dc7c4
--- /dev/null
+++ b/tests/format/variables/public_data_variables/project.conf
@@ -0,0 +1,5 @@
+name: foo
+min-version: 2.0
+
+variables:
+ expand-me: "expanded"
diff --git a/tests/format/variables/public_data_variables/public.bst b/tests/format/variables/public_data_variables/public.bst
new file mode 100644
index 000000000..e5273e89a
--- /dev/null
+++ b/tests/format/variables/public_data_variables/public.bst
@@ -0,0 +1,11 @@
+kind: import
+
+sources:
+ - kind: local
+ path: public.bst
+
+public:
+ integration-commands:
+ - echo %{expand-me}
+
+ test: "%{expand-me}"
diff --git a/tests/format/variables/public_data_variables/public_unresolved.bst b/tests/format/variables/public_data_variables/public_unresolved.bst
new file mode 100644
index 000000000..024075134
--- /dev/null
+++ b/tests/format/variables/public_data_variables/public_unresolved.bst
@@ -0,0 +1,9 @@
+kind: import
+
+sources:
+ - kind: local
+ path: public_unresolved.bst
+
+public:
+ integration-commands:
+ - echo %{non-existent}