You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:01:53 UTC

[buildstream] 03/27: tests/frontend/overlaps.py: Test undefined variables

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

github-bot pushed a commit to branch tristan/partial-variables-manual-string-join
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 24503c3fc3787b7516801fec43cd35869e992a37
Author: Tristan van Berkom <tr...@codethink.co.uk>
AuthorDate: Mon Jun 29 19:59:53 2020 +0900

    tests/frontend/overlaps.py: Test undefined variables
    
    Ensure that we get the expected provenance when expanding a variable
    included in an overlap whitelist entry.
---
 tests/frontend/overlaps.py                      | 15 ++++++++++++++-
 tests/frontend/overlaps/whitelist-undefined.bst | 13 +++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/tests/frontend/overlaps.py b/tests/frontend/overlaps.py
index a45fc70..28bf8a7 100644
--- a/tests/frontend/overlaps.py
+++ b/tests/frontend/overlaps.py
@@ -4,7 +4,7 @@
 import os
 import pytest
 from buildstream.testing.runcli import cli  # pylint: disable=unused-import
-from buildstream.exceptions import ErrorDomain
+from buildstream.exceptions import ErrorDomain, LoadErrorReason
 from buildstream import _yaml
 from buildstream.plugin import CoreWarnings
 from tests.testutils import generate_junction
@@ -71,6 +71,19 @@ 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", "whitelist-undefined.bst"])
+
+    # Assert that we get the expected undefined variable error,
+    # and that it has the provenance we expect from whitelist-undefined.bst
+    #
+    result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNRESOLVED_VARIABLE)
+    assert "whitelist-undefined.bst [line 13 column 6]" 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/whitelist-undefined.bst b/tests/frontend/overlaps/whitelist-undefined.bst
new file mode 100644
index 0000000..5cb0c64
--- /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}/*"