summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-16 22:40:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-16 22:40:44 +0100
commitbc162d21dd148252efcf3ed771e04c791ef4d869 (patch)
tree96e8790420c95ecb60f51d1ccbfa5f303d57b6be /bitbake
parentc2bb6022fe5e9f6fe15d67ec03a7073b0f99bc61 (diff)
downloadpoky-bc162d21dd148252efcf3ed771e04c791ef4d869.tar.gz
bitbake: tests/parse: Add file missing from previous commit
(Bitbake rev: 76f095107a0eaf987a5a6a48eed7b98f87aea121) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/tests/parse.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py
new file mode 100644
index 0000000000..fa40327339
--- /dev/null
+++ b/bitbake/lib/bb/tests/parse.py
@@ -0,0 +1,69 @@
1# ex:ts=4:sw=4:sts=4:et
2# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
3#
4# BitBake Test for lib/bb/parse/
5#
6# Copyright (C) 2015 Richard Purdie
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License version 2 as
10# published by the Free Software Foundation.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program; if not, write to the Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20#
21
22import unittest
23import tempfile
24import logging
25import bb
26import os
27
28logger = logging.getLogger('BitBake.TestParse')
29
30import bb.parse
31import bb.data
32import bb.siggen
33
34class ParseTest(unittest.TestCase):
35
36 testfile = """
37A = "1"
38B = "2"
39do_install() {
40 echo "hello"
41}
42
43C = "3"
44"""
45
46 def setUp(self):
47 self.d = bb.data.init()
48 bb.parse.siggen = bb.siggen.init(self.d)
49
50 def parsehelper(self, content):
51
52 f = tempfile.NamedTemporaryFile(suffix = ".bb")
53 f.write(content)
54 f.flush()
55 os.chdir(os.path.dirname(f.name))
56 return f
57
58 def test_parse_simple(self):
59 f = self.parsehelper(self.testfile)
60 d = bb.parse.handle(f.name, self.d)['']
61 self.assertEqual(d.getVar("A", True), "1")
62 self.assertEqual(d.getVar("B", True), "2")
63 self.assertEqual(d.getVar("C", True), "3")
64
65 def test_parse_incomplete_function(self):
66 testfileB = self.testfile.replace("}", "")
67 f = self.parsehelper(testfileB)
68 with self.assertRaises(bb.parse.ParseError):
69 d = bb.parse.handle(f.name, self.d)['']