summaryrefslogtreecommitdiff
path: root/tests/format
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2018-10-23 11:21:59 +0100
committerJürg Billeter <j@bitron.ch>2019-02-11 09:24:48 +0000
commit4336e3bfff34e3d1bd1cf5ee4816ba1aa14b9f01 (patch)
tree53f3fd3caa60676b6b016b7f49f76a65936c707b /tests/format
parent02e48209ec7af316afc8390dcb14d1135115878b (diff)
downloadbuildstream-4336e3bfff34e3d1bd1cf5ee4816ba1aa14b9f01.tar.gz
_includes: better error on including directory
Previously, include a directory result in an error like this: mydir is a directory. bst command expects a .bst file. Note that the file containing the include was not mentioned. Now we get an error like this instead: element.bst [line 12 column 0]: Include block references a directory instead of a file: 'mydir'.
Diffstat (limited to 'tests/format')
-rw-r--r--tests/format/include.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/format/include.py b/tests/format/include.py
index 536f9faaf..95b78d96e 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -47,6 +47,27 @@ def test_include_missing_file(cli, tmpdir):
assert 'line 4 column 2' in result.stderr
+def test_include_dir(cli, tmpdir):
+ tmpdir.join('project.conf').write('{"name": "test"}')
+ tmpdir.mkdir('subdir')
+ element = tmpdir.join('include_dir.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
+
+ "(@)":
+ - subdir/
+ """).strip())
+
+ result = cli.run(project=str(tmpdir), args=['show', str(element.basename)])
+ result.assert_main_error(
+ ErrorDomain.LOAD, LoadErrorReason.LOADING_DIRECTORY)
+ # 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')