summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tests/parse.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-09-13 04:26:39 -1000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-09-16 17:53:22 +0100
commit34ce1874911fcb34052ab6c032e1b342e51f9567 (patch)
treeb2c739546f463211e65e4ba2b60ab7db59032757 /bitbake/lib/bb/tests/parse.py
parent43e98fb4551fe728be3544e982ac70f4056d49e9 (diff)
downloadpoky-34ce1874911fcb34052ab6c032e1b342e51f9567.tar.gz
bitbake: ConfHandler/BBHandler: Improve comment error messages and add tests
Currently if you trigger one of the comment errors, the newline characters are stripped and the line numbers are incorrect. In one case it prints the empty line which is also unhelpful. Rework the code around these errors so the line numbers are correct and the lines in question are more clearly displayed complete with newlines so the user can more clearly see the error. I also added a couple of simplistic test cases to ensure that errors are raised by the two known comment format errors. [YOCTO #11904] (Bitbake rev: 01d27562c11d4b05eb30c7f9fefd58b6599fdd15) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 712da71b24445c814d79a206ce26188def8fce0a) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/tests/parse.py')
-rw-r--r--bitbake/lib/bb/tests/parse.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py
index 2898f9bb14..1a3b74934d 100644
--- a/bitbake/lib/bb/tests/parse.py
+++ b/bitbake/lib/bb/tests/parse.py
@@ -194,3 +194,26 @@ deltask ${EMPTYVAR}
194 self.assertTrue('addtask ignored: " do_patch"' in stdout) 194 self.assertTrue('addtask ignored: " do_patch"' in stdout)
195 #self.assertTrue('dependent task do_foo for do_patch does not exist' in stdout) 195 #self.assertTrue('dependent task do_foo for do_patch does not exist' in stdout)
196 196
197 broken_multiline_comment = """
198# First line of comment \\
199# Second line of comment \\
200
201"""
202 def test_parse_broken_multiline_comment(self):
203 f = self.parsehelper(self.broken_multiline_comment)
204 with self.assertRaises(bb.BBHandledException):
205 d = bb.parse.handle(f.name, self.d)['']
206
207
208 comment_in_var = """
209VAR = " \\
210 SOMEVAL \\
211# some comment \\
212 SOMEOTHERVAL \\
213"
214"""
215 def test_parse_comment_in_var(self):
216 f = self.parsehelper(self.comment_in_var)
217 with self.assertRaises(bb.BBHandledException):
218 d = bb.parse.handle(f.name, self.d)['']
219