diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-21 14:05:43 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-01-22 12:01:24 +0000 |
commit | cf9cb65eeccf26310177e4013848ebc609dfdb31 (patch) | |
tree | 77ef4544619bbb1b5e968c3147d4f85c084db528 /bitbake/lib/bb/tests | |
parent | b80219eac1695044554c18994124ae32c04642c6 (diff) | |
download | poky-cf9cb65eeccf26310177e4013848ebc609dfdb31.tar.gz |
bitbake: data_smart: Don't show exceptions for EOL literals
If variables are unset, the code simply doesn't expand them, there
aren't errors. If the code is a python expression, this can get a bit
messy, see the attached test case. The python expansion code sees the }
of the unexpanded value rather than the close of the python expression
and then raises a SyntaxError exception.
Ideally, we'd update the code to match pairs of brackets. I don't know
how to do that with the current regex and this is unfortunately a
performance sensitive piece of code. We also run the risk of breaking
existing code in OE-Core where there are "{" characters but not "}"
to close them (PKGE and PE).
Rather than raising the exception, matching the existing "just return
the expression" behaviour seems more consistent with the standard
variable behaviour.
This addresses an issue found in the recent image.bbclass code where
there are some variables we choose not to expand (TMPDIR/DATETIME).
This patch also adds a test case for this behaviour. It wouldn't preclude
improved bracket matching code in the future either.
(Bitbake rev: d80d39e73223a50fda0090784303d2c57167bb4c)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests')
-rw-r--r-- | bitbake/lib/bb/tests/data.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index e9aab577f6..a96078fa9c 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
@@ -80,6 +80,11 @@ class DataExpansions(unittest.TestCase): | |||
80 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") | 80 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") |
81 | self.assertEqual(str(val), "value_of_foo value_of_bar") | 81 | self.assertEqual(str(val), "value_of_foo value_of_bar") |
82 | 82 | ||
83 | def test_python_unexpanded(self): | ||
84 | self.d.setVar("bar", "${unsetvar}") | ||
85 | val = self.d.expand("${@d.getVar('foo', True) + ' ${bar}'}") | ||
86 | self.assertEqual(str(val), "${@d.getVar('foo', True) + ' ${unsetvar}'}") | ||
87 | |||
83 | def test_python_snippet_syntax_error(self): | 88 | def test_python_snippet_syntax_error(self): |
84 | self.d.setVar("FOO", "${@foo = 5}") | 89 | self.d.setVar("FOO", "${@foo = 5}") |
85 | self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True) | 90 | self.assertRaises(bb.data_smart.ExpansionError, self.d.getVar, "FOO", True) |