summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2018-10-23 09:31:16 +0100
committerJürg Billeter <j@bitron.ch>2019-02-11 09:24:48 +0000
commit02e48209ec7af316afc8390dcb14d1135115878b (patch)
treec7d18edbc45b76dcdc86c7a8c86c57bf40c3eb96 /tests
parent1ed63e542797f5097a1c9a1952fd50e435e1783a (diff)
downloadbuildstream-02e48209ec7af316afc8390dcb14d1135115878b.tar.gz
_includes: better error on missing include
Previously, a missing include would result in an error like this: Could not find file at not-a-file.include Note that the file containing the include was not mentioned. Now we get an error like this instead: element.bst [line 7 column 5]: Include block references a file that could not be found: 'not-a-file.include'.
Diffstat (limited to 'tests')
-rw-r--r--tests/format/include.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/format/include.py b/tests/format/include.py
index 7344919ba..536f9faaf 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -1,4 +1,5 @@
import os
+import textwrap
import pytest
from buildstream import _yaml
from buildstream._exceptions import ErrorDomain, LoadErrorReason
@@ -27,6 +28,25 @@ def test_include_project_file(cli, datafiles):
assert loaded['included'] == 'True'
+def test_include_missing_file(cli, tmpdir):
+ tmpdir.join('project.conf').write('{"name": "test"}')
+ element = tmpdir.join('include_missing_file.bst')
+
+ # Normally we would use dicts and _yaml.dump to write such things, but here
+ # we want to be sure of a stable line and column number.
+ element.write(textwrap.dedent("""
+ kind: manual
+
+ "(@)":
+ - nosuch.yaml
+ """).strip())
+
+ result = cli.run(project=str(tmpdir), args=['show', str(element.basename)])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
+ # Make sure the root cause provenance is in the output.
+ assert 'line 4 column 2' in result.stderr
+
+
@pytest.mark.datafiles(DATA_DIR)
def test_include_junction_file(cli, tmpdir, datafiles):
project = os.path.join(str(datafiles), 'junction')