summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/tests/parse.py60
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 = """
453EXTRA_OECONF:append = " foo"
454"""
455
456 someconf2 = """
457EXTRA_OECONF:append = " bar"
458"""
459
460 someconf3 = """
461EXTRA_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")