diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-17 10:13:43 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-07-17 10:13:43 +0000 |
commit | 6160a64cfc4788d9c7e0519b77f55ed870b6a6a7 (patch) | |
tree | 015ef9a27ab035d671d98d91372d9f86eaf5a95d | |
parent | 9b2cac15e57d879f3a5da8f0f9e013ba533f4d15 (diff) | |
parent | 2bd91640f4ba7e29d92633f7e573deb2073dc27d (diff) | |
download | buildstream-6160a64cfc4788d9c7e0519b77f55ed870b6a6a7.tar.gz |
Merge branch 'bschubert/fix-missing-variable-provenance' into 'master'
_variables: Fix reporting of missing variable
See merge request BuildStream/buildstream!1485
-rw-r--r-- | src/buildstream/_variables.pyx | 2 | ||||
-rw-r--r-- | tests/format/variables.py | 5 | ||||
-rw-r--r-- | tests/format/variables/missing_variables/manual2.bst | 4 |
3 files changed, 8 insertions, 3 deletions
diff --git a/src/buildstream/_variables.pyx b/src/buildstream/_variables.pyx index 470feddc9..8f91c9ced 100644 --- a/src/buildstream/_variables.pyx +++ b/src/buildstream/_variables.pyx @@ -139,7 +139,7 @@ cdef class Variables: for var in expstr[1::2]: if var not in self._expstr_map: line = " unresolved variable '{unmatched}' in declaration of '{variable}' at: {provenance}" - provenance = expstr.get_provenance() + provenance = self.original.get_scalar(key).get_provenance() summary.append(line.format(unmatched=var, variable=key, provenance=provenance)) if summary: raise LoadError(LoadErrorReason.UNRESOLVED_VARIABLE, diff --git a/tests/format/variables.py b/tests/format/variables.py index 93814279a..4610e039f 100644 --- a/tests/format/variables.py +++ b/tests/format/variables.py @@ -78,11 +78,12 @@ def test_overrides(cli, datafiles, target, varname, expected): assert result_vars.get_str(varname) == expected +@pytest.mark.parametrize("element", ["manual.bst", "manual2.bst"]) @pytest.mark.datafiles(os.path.join(DATA_DIR, 'missing_variables')) -def test_missing_variable(cli, datafiles): +def test_missing_variable(cli, datafiles, element): project = str(datafiles) result = cli.run(project=project, silent=True, args=[ - 'show', '--deps', 'none', '--format', '%{config}', 'manual.bst' + 'show', '--deps', 'none', '--format', '%{config}', element ]) result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.UNRESOLVED_VARIABLE) diff --git a/tests/format/variables/missing_variables/manual2.bst b/tests/format/variables/missing_variables/manual2.bst new file mode 100644 index 000000000..bd8e2baf7 --- /dev/null +++ b/tests/format/variables/missing_variables/manual2.bst @@ -0,0 +1,4 @@ +kind: manual + +variables: + test: hello %{missing} |