summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan van Berkom <tristan.vanberkom@codethink.co.uk>2020-06-29 19:59:53 +0900
committerTristan van Berkom <tristan.vanberkom@codethink.co.uk>2020-07-22 18:41:54 +0900
commitdcaaa0be1924a503fe05c63112cfcaf3335eed05 (patch)
tree1a3bb04c607ed1475c11b8f23cfe8b9d37c6230f
parenta0517233e23fe1c9645c5099d4644b775290040d (diff)
downloadbuildstream-tristan/bst-1/partial-variables.tar.gz
tests/frontend/overlaps.py: Test undefined variablestristan/bst-1/partial-variables
Ensure that we get the expected provenance when expanding a variable included in an overlap whitelist entry.
-rw-r--r--tests/frontend/overlaps.py22
-rw-r--r--tests/frontend/overlaps/collect-whitelisted-undefined.bst9
-rw-r--r--tests/frontend/overlaps/whitelist-undefined.bst13
3 files changed, 43 insertions, 1 deletions
diff --git a/tests/frontend/overlaps.py b/tests/frontend/overlaps.py
index ad2211dde..1ea6d157c 100644
--- a/tests/frontend/overlaps.py
+++ b/tests/frontend/overlaps.py
@@ -2,7 +2,7 @@ import os
import pytest
from tests.testutils.runcli import cli
from tests.testutils import generate_junction
-from buildstream._exceptions import ErrorDomain
+from buildstream._exceptions import ErrorDomain, LoadErrorReason
from buildstream import _yaml
from buildstream.plugin import CoreWarnings
@@ -80,6 +80,26 @@ def test_overlaps_whitelist_on_overlapper(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
+def test_overlaps_whitelist_undefined_variable(cli, datafiles):
+ project_dir = str(datafiles)
+ gen_project(project_dir, False)
+ result = cli.run(project=project_dir, silent=True, args=["build", "collect-whitelisted-undefined.bst"])
+
+ # Assert that we get the expected undefined variable error,
+ # and that it has the provenance we expect from whitelist-undefined.bst
+ #
+ # FIXME: In BuildStream 1, we only encounter this error later when extracting
+ # the variables from an artifact, and we lose the provenance.
+ #
+ # This is not a huge problem in light of the coming of BuildStream 2 and
+ # is probably not worth too much attention, but it is worth noting that
+ # this is an imperfect error message delivered at a late stage.
+ #
+ result.assert_main_error(ErrorDomain.STREAM, None)
+ assert "public.yaml [line 3 column 4]" in result.stderr
+
+
+@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("use_fatal_warnings", [True, False])
def test_overlaps_script(cli, datafiles, use_fatal_warnings):
# Test overlaps with script element to test
diff --git a/tests/frontend/overlaps/collect-whitelisted-undefined.bst b/tests/frontend/overlaps/collect-whitelisted-undefined.bst
new file mode 100644
index 000000000..9572cd6a0
--- /dev/null
+++ b/tests/frontend/overlaps/collect-whitelisted-undefined.bst
@@ -0,0 +1,9 @@
+kind: compose
+
+depends:
+- filename: a-whitelisted.bst
+ type: build
+- filename: whitelist-undefined.bst
+ type: build
+- filename: c.bst
+ type: build
diff --git a/tests/frontend/overlaps/whitelist-undefined.bst b/tests/frontend/overlaps/whitelist-undefined.bst
new file mode 100644
index 000000000..5cb0c645e
--- /dev/null
+++ b/tests/frontend/overlaps/whitelist-undefined.bst
@@ -0,0 +1,13 @@
+kind: import
+config:
+ source: /
+ target: /
+depends:
+- b-whitelisted.bst
+sources:
+- kind: local
+ path: "a"
+public:
+ bst:
+ overlap-whitelist:
+ - "%{undefined-variable}/*"