diff options
| author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2025-09-16 23:19:32 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-09-24 00:01:44 +0100 |
| commit | 44029f9fb590b7f15abbea94ce40343947d11047 (patch) | |
| tree | 7b8e4c0123b64053add76a942b42c4a3c4179adb /bitbake/lib/bb | |
| parent | 6cfa08f301f813a688fc8c09d09dcec4cd66eb3b (diff) | |
| download | poky-44029f9fb590b7f15abbea94ce40343947d11047.tar.gz | |
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>
Diffstat (limited to 'bitbake/lib/bb')
| -rw-r--r-- | bitbake/lib/bb/tests/parse.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py index 431b0c7d3e..d3867ece98 100644 --- a/bitbake/lib/bb/tests/parse.py +++ b/bitbake/lib/bb/tests/parse.py | |||
| @@ -448,3 +448,63 @@ A+ = "b" | |||
| 448 | with self.assertRaises(bb.parse.ParseError) as error: | 448 | with self.assertRaises(bb.parse.ParseError) as error: |
| 449 | bb.parse.handle(f.name, self.d) | 449 | bb.parse.handle(f.name, self.d) |
| 450 | self.assertIn("Empty variable name in assignment", str(error.exception)) | 450 | self.assertIn("Empty variable name in assignment", str(error.exception)) |
| 451 | |||
| 452 | someconf1 = """ | ||
| 453 | EXTRA_OECONF:append = " foo" | ||
| 454 | """ | ||
| 455 | |||
| 456 | someconf2 = """ | ||
| 457 | EXTRA_OECONF:append = " bar" | ||
| 458 | """ | ||
| 459 | |||
| 460 | someconf3 = """ | ||
| 461 | EXTRA_OECONF:append = " foobar" | ||
| 462 | """ | ||
| 463 | |||
| 464 | def test_include_and_require(self): | ||
| 465 | def test_helper(content, result): | ||
| 466 | with self.parsehelper(content) as f: | ||
| 467 | if isinstance(result, type) and issubclass(result, Exception): | ||
| 468 | with self.assertRaises(result): | ||
| 469 | d = bb.parse.handle(f.name, bb.data.createCopy(self.d))[''] | ||
| 470 | else: | ||
| 471 | d = bb.parse.handle(f.name, bb.data.createCopy(self.d))[''] | ||
| 472 | self.assertEqual(d.getVar("EXTRA_OECONF"), result) | ||
| 473 | |||
| 474 | with tempfile.TemporaryDirectory() as tempdir: | ||
| 475 | os.makedirs(tempdir + "/conf1") | ||
| 476 | os.makedirs(tempdir + "/conf2") | ||
| 477 | |||
| 478 | with open(tempdir + "/conf1/some.conf", "w") as f: | ||
| 479 | f.write(self.someconf1) | ||
| 480 | with open(tempdir + "/conf2/some.conf", "w") as f: | ||
| 481 | f.write(self.someconf2) | ||
| 482 | with open(tempdir + "/conf2/some3.conf", "w") as f: | ||
| 483 | f.write(self.someconf3) | ||
| 484 | |||
| 485 | self.d.setVar("BBPATH", tempdir + "/conf1" + ":" + tempdir + "/conf2") | ||
| 486 | |||
| 487 | test_helper("include some.conf", " foo") | ||
| 488 | test_helper("include someother.conf", None) | ||
| 489 | test_helper("include some3.conf", " foobar") | ||
| 490 | test_helper("include ${@''}", None) | ||
| 491 | test_helper("include " + tempdir + "/conf2/some.conf", " bar") | ||
| 492 | |||
| 493 | test_helper("require some.conf", " foo") | ||
| 494 | test_helper("require someother.conf", bb.parse.ParseError) | ||
| 495 | test_helper("require some3.conf", " foobar") | ||
| 496 | test_helper("require ${@''}", None) | ||
| 497 | test_helper("require " + tempdir + "/conf2/some.conf", " bar") | ||
| 498 | |||
| 499 | test_helper("include_all some.conf", " foo bar") | ||
| 500 | test_helper("include_all someother.conf", None) | ||
| 501 | test_helper("include_all some3.conf", " foobar") | ||
| 502 | |||
| 503 | self.d.setVar("BBPATH", tempdir + "/conf2" + ":" + tempdir + "/conf1") | ||
| 504 | |||
| 505 | test_helper("include some.conf", " bar") | ||
| 506 | test_helper("include some3.conf", " foobar") | ||
| 507 | test_helper("require some.conf", " bar") | ||
| 508 | test_helper("require some3.conf", " foobar") | ||
| 509 | test_helper("include_all some.conf", " bar foo") | ||
| 510 | test_helper("include_all some3.conf", " foobar") | ||
