mirror of
https://git.yoctoproject.org/poky
synced 2026-04-26 18:32:13 +02:00
bitbake: tests/parse: Add tests for include, require and include_all
Simple tests for various ways to include and require configuration files. (Bitbake rev: bdcb67824172ed5cd76fa0274dc3d27aeb52e77c) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
6cfa08f301
commit
44029f9fb5
@@ -448,3 +448,63 @@ A+ = "b"
|
||||
with self.assertRaises(bb.parse.ParseError) as error:
|
||||
bb.parse.handle(f.name, self.d)
|
||||
self.assertIn("Empty variable name in assignment", str(error.exception))
|
||||
|
||||
someconf1 = """
|
||||
EXTRA_OECONF:append = " foo"
|
||||
"""
|
||||
|
||||
someconf2 = """
|
||||
EXTRA_OECONF:append = " bar"
|
||||
"""
|
||||
|
||||
someconf3 = """
|
||||
EXTRA_OECONF:append = " foobar"
|
||||
"""
|
||||
|
||||
def test_include_and_require(self):
|
||||
def test_helper(content, result):
|
||||
with self.parsehelper(content) as f:
|
||||
if isinstance(result, type) and issubclass(result, Exception):
|
||||
with self.assertRaises(result):
|
||||
d = bb.parse.handle(f.name, bb.data.createCopy(self.d))['']
|
||||
else:
|
||||
d = bb.parse.handle(f.name, bb.data.createCopy(self.d))['']
|
||||
self.assertEqual(d.getVar("EXTRA_OECONF"), result)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
os.makedirs(tempdir + "/conf1")
|
||||
os.makedirs(tempdir + "/conf2")
|
||||
|
||||
with open(tempdir + "/conf1/some.conf", "w") as f:
|
||||
f.write(self.someconf1)
|
||||
with open(tempdir + "/conf2/some.conf", "w") as f:
|
||||
f.write(self.someconf2)
|
||||
with open(tempdir + "/conf2/some3.conf", "w") as f:
|
||||
f.write(self.someconf3)
|
||||
|
||||
self.d.setVar("BBPATH", tempdir + "/conf1" + ":" + tempdir + "/conf2")
|
||||
|
||||
test_helper("include some.conf", " foo")
|
||||
test_helper("include someother.conf", None)
|
||||
test_helper("include some3.conf", " foobar")
|
||||
test_helper("include ${@''}", None)
|
||||
test_helper("include " + tempdir + "/conf2/some.conf", " bar")
|
||||
|
||||
test_helper("require some.conf", " foo")
|
||||
test_helper("require someother.conf", bb.parse.ParseError)
|
||||
test_helper("require some3.conf", " foobar")
|
||||
test_helper("require ${@''}", None)
|
||||
test_helper("require " + tempdir + "/conf2/some.conf", " bar")
|
||||
|
||||
test_helper("include_all some.conf", " foo bar")
|
||||
test_helper("include_all someother.conf", None)
|
||||
test_helper("include_all some3.conf", " foobar")
|
||||
|
||||
self.d.setVar("BBPATH", tempdir + "/conf2" + ":" + tempdir + "/conf1")
|
||||
|
||||
test_helper("include some.conf", " bar")
|
||||
test_helper("include some3.conf", " foobar")
|
||||
test_helper("require some.conf", " bar")
|
||||
test_helper("require some3.conf", " foobar")
|
||||
test_helper("include_all some.conf", " bar foo")
|
||||
test_helper("include_all some3.conf", " foobar")
|
||||
|
||||
Reference in New Issue
Block a user