diff options
-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} |