diff options
| -rw-r--r-- | bitbake/lib/bb/tests/data.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/bitbake/lib/bb/tests/data.py b/bitbake/lib/bb/tests/data.py index 8279115e03..9ac78e3683 100644 --- a/bitbake/lib/bb/tests/data.py +++ b/bitbake/lib/bb/tests/data.py | |||
| @@ -455,6 +455,54 @@ class Contains(unittest.TestCase): | |||
| 455 | self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d)) | 455 | self.assertFalse(bb.utils.contains_any("SOMEFLAG", "x y z", True, False, self.d)) |
| 456 | 456 | ||
| 457 | 457 | ||
| 458 | class TaskHash(unittest.TestCase): | ||
| 459 | def test_taskhashes(self): | ||
| 460 | def gettask_bashhash(taskname, d): | ||
| 461 | tasklist, gendeps, lookupcache = bb.data.generate_dependencies(d) | ||
| 462 | taskdeps, basehash = bb.data.generate_dependency_hash(tasklist, gendeps, lookupcache, set(), "somefile") | ||
| 463 | bb.warn(str(lookupcache)) | ||
| 464 | return basehash["somefile." + taskname] | ||
| 465 | |||
| 466 | d = bb.data.init() | ||
| 467 | d.setVar("__BBTASKS", ["mytask"]) | ||
| 468 | d.setVar("__exportlist", []) | ||
| 469 | d.setVar("mytask", "${MYCOMMAND}") | ||
| 470 | d.setVar("MYCOMMAND", "${VAR}; foo; bar; exit 0") | ||
| 471 | d.setVar("VAR", "val") | ||
| 472 | orighash = gettask_bashhash("mytask", d) | ||
| 473 | |||
| 474 | # Changing a variable should change the hash | ||
| 475 | d.setVar("VAR", "val2") | ||
| 476 | nexthash = gettask_bashhash("mytask", d) | ||
| 477 | self.assertNotEqual(orighash, nexthash) | ||
| 478 | |||
| 479 | d.setVar("VAR", "val") | ||
| 480 | # Adding an inactive removal shouldn't change the hash | ||
| 481 | d.setVar("BAR", "notbar") | ||
| 482 | d.setVar("MYCOMMAND_remove", "${BAR}") | ||
| 483 | nexthash = gettask_bashhash("mytask", d) | ||
| 484 | self.assertEqual(orighash, nexthash) | ||
| 485 | |||
| 486 | # Adding an active removal should change the hash | ||
| 487 | d.setVar("BAR", "bar;") | ||
| 488 | nexthash = gettask_bashhash("mytask", d) | ||
| 489 | self.assertNotEqual(orighash, nexthash) | ||
| 490 | |||
| 491 | # Setup an inactive contains() | ||
| 492 | d.setVar("VAR", "${@bb.utils.contains('VAR2', 'A', 'val', '', d)}") | ||
| 493 | orighash = gettask_bashhash("mytask", d) | ||
| 494 | |||
| 495 | # Activate the contains() and the hash should change | ||
| 496 | d.setVar("VAR2", "A") | ||
| 497 | nexthash = gettask_bashhash("mytask", d) | ||
| 498 | self.assertNotEqual(orighash, nexthash) | ||
| 499 | |||
| 500 | # The contains should be inactive but even though VAR2 has a | ||
| 501 | # different value the hash should match the original | ||
| 502 | d.setVar("VAR2", "B") | ||
| 503 | nexthash = gettask_bashhash("mytask", d) | ||
| 504 | self.assertEqual(orighash, nexthash) | ||
| 505 | |||
| 458 | class Serialize(unittest.TestCase): | 506 | class Serialize(unittest.TestCase): |
| 459 | 507 | ||
| 460 | def test_serialize(self): | 508 | def test_serialize(self): |
