diff options
author | Angelos Evripiotis <jevripiotis@bloomberg.net> | 2018-10-23 09:29:08 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-02-11 09:24:48 +0000 |
commit | 1ed63e542797f5097a1c9a1952fd50e435e1783a (patch) | |
tree | 8e8704a4725c84d4072e4ac755a6deaccd152da4 | |
parent | bb6a692de806dbceeba6eda95a3987cf2da576c1 (diff) | |
download | buildstream-1ed63e542797f5097a1c9a1952fd50e435e1783a.tar.gz |
_includes: better provenance on recursive include
Use the provenance of the include block, instead of the whole node.
-rw-r--r-- | buildstream/_includes.py | 6 | ||||
-rw-r--r-- | tests/format/include.py | 3 |
2 files changed, 6 insertions, 3 deletions
diff --git a/buildstream/_includes.py b/buildstream/_includes.py index df14c9f2d..d27f901a0 100644 --- a/buildstream/_includes.py +++ b/buildstream/_includes.py @@ -40,7 +40,10 @@ class Includes: includes = [_yaml.node_get(node, str, '(@)')] else: includes = _yaml.node_get(node, list, '(@)', default_value=None) + + include_provenance = None if '(@)' in node: + include_provenance = _yaml.node_get_provenance(node, key='(@)') del node['(@)'] if includes: @@ -50,9 +53,8 @@ class Includes: include_node, file_path, sub_loader = self._include_file(include, current_loader) if file_path in included: - provenance = _yaml.node_get_provenance(node) raise LoadError(LoadErrorReason.RECURSIVE_INCLUDE, - "{}: trying to recursively include {}". format(provenance, + "{}: trying to recursively include {}". format(include_provenance, file_path)) # Because the included node will be modified, we need # to copy it so that we do not modify the toplevel diff --git a/tests/format/include.py b/tests/format/include.py index 1db37083e..7344919ba 100644 --- a/tests/format/include.py +++ b/tests/format/include.py @@ -222,7 +222,7 @@ def test_inner(cli, datafiles): @pytest.mark.datafiles(DATA_DIR) -def test_recusive_include(cli, tmpdir, datafiles): +def test_recursive_include(cli, tmpdir, datafiles): project = os.path.join(str(datafiles), 'recursive') result = cli.run(project=project, args=[ @@ -231,6 +231,7 @@ def test_recusive_include(cli, tmpdir, datafiles): '--format', '%{vars}', 'element.bst']) result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.RECURSIVE_INCLUDE) + assert 'line 2 column 2' in result.stderr @pytest.mark.datafiles(DATA_DIR) |