summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin David <valentin.david@codethink.co.uk>2018-05-04 13:10:23 +0200
committerValentin David <valentin.david@codethink.co.uk>2018-05-04 13:44:20 +0200
commit0ea453b5944ddab247ebbf3026b934b2c6f85b04 (patch)
tree67a12572e140a066b1547a2b188c2c0146c15486
parent20464d5f1d9f883740d7098045d647fb845c9ead (diff)
downloadbuildstream-valentindavid/253_better_missing_variable_errors.tar.gz
tests/format/variables.py: Add a test for undefined variable error messagevalentindavid/253_better_missing_variable_errors
-rw-r--r--tests/format/variables.py14
-rw-r--r--tests/format/variables/missing_variables/manual.bst7
-rw-r--r--tests/format/variables/missing_variables/project.conf3
3 files changed, 24 insertions, 0 deletions
diff --git a/tests/format/variables.py b/tests/format/variables.py
index 1d34911ea..66c56b451 100644
--- a/tests/format/variables.py
+++ b/tests/format/variables.py
@@ -62,3 +62,17 @@ def test_overrides(cli, datafiles, tmpdir, target, varname, expected):
result.assert_success()
result_vars = _yaml.load_data(result.output)
assert result_vars[varname] == expected
+
+
+@pytest.mark.datafiles(os.path.join(DATA_DIR, 'missing_variables'))
+def test_missing_variable(cli, datafiles, tmpdir):
+ project = os.path.join(datafiles.dirname, datafiles.basename)
+ result = cli.run(project=project, silent=True, args=[
+ 'show', '--deps', 'none', '--format', '%{config}', 'manual.bst'
+ ])
+ result.assert_main_error(ErrorDomain.LOAD,
+ LoadErrorReason.UNRESOLVED_VARIABLE)
+ expected = ("Error loading pipeline: "
+ "manual.bst [line 5 column 6]: "
+ "Unresolved variable 'foo'")
+ assert expected in result.stderr.splitlines()
diff --git a/tests/format/variables/missing_variables/manual.bst b/tests/format/variables/missing_variables/manual.bst
new file mode 100644
index 000000000..1f442e17c
--- /dev/null
+++ b/tests/format/variables/missing_variables/manual.bst
@@ -0,0 +1,7 @@
+kind: manual
+
+config:
+ build-commands:
+ - some undefined variable %{foo}
+
+
diff --git a/tests/format/variables/missing_variables/project.conf b/tests/format/variables/missing_variables/project.conf
new file mode 100644
index 000000000..2027cc27a
--- /dev/null
+++ b/tests/format/variables/missing_variables/project.conf
@@ -0,0 +1,3 @@
+# Basic project configuration that doesnt override anything
+#
+name: pony