示例#1
0
 def test_not_memoized(self):
     d1 = bb.data.init()
     d2 = bb.data.init()
     d1.setVar("FOO", "bar")
     d2.setVar("FOO", "bar")
     self.assertTrue(bbvalue.bbvalue("FOO", d1) is not
                     bbvalue.bbvalue("FOO", d2))
示例#2
0
 def test_changed_after_memoized(self):
     d = bb.data.init()
     d.setVar("foo", "value of foo")
     val = bbvalue.bbparse("${foo}", d)
     self.assertEqual(str(bbvalue.bbvalue("foo", d)), "value of foo")
     d.setVar("foo", "second value of foo")
     self.assertEqual(str(bbvalue.bbvalue("foo", d)), "second value of foo")
示例#3
0
 def test_normal_append(self):
     value = bbvalue.LazyCompound(self.metadata)
     value.append(bbvalue.bbvalue("VAL", self.metadata))
     value.lazy_prepend(bbvalue.bbparse("${FOO}:", self.metadata))
     value.lazy_append(bbvalue.bbparse(":${BAR}", self.metadata))
     value.append(bbvalue.bbparse(":val2", self.metadata))
     self.assertEqual(value.resolve(), "foo:val:val2:bar")
示例#4
0
        def data_for_hash(key, seen):
            """Returns an iterator over the variable names and their values, including references"""

            if key in seen:
                return
            seen.add(key)
            if self.is_blacklisted(key):
                return

            valstr = self.metadata.getVar(key, False)
            if valstr is not None:
                try:
                    value = self.transform_blacklisted(
                        bbvalue.bbvalue(key, self.metadata))
                except (SyntaxError, NotImplementedError,
                        bbvalue.PythonExpansionError, 
                        bbvalue.RecursionError), exc:
                    msg.error(None, "Unable to parse %s, excluding from signature: %s" %
                                 (key, exc))
                else:
                    yield key, value

                    refs = reftracker.references(value, self.metadata)
                    refs |= reftracker.references_from_flags(key, self.metadata)
                    for ref in refs:
                        for other in data_for_hash(ref, seen):
                            yield other
示例#5
0
    def test_python(self):
        self.d.setVar("FOO", self.pydata)
        self.d.setVarFlags("FOO", {"func": True, "python": True})

        value = bbvalue.bbvalue("FOO", self.d)
        self.assertEquals(reftracker.references(value, self.d),
                          set(["somevar", "bar", "something", "inexpand"]))
        self.assertEquals(reftracker.calls(value, self.d), 
                          set(["test", "test2", "a"]))
示例#6
0
 def test_recursion_exception(self):
     self.d.setVar("FOO", "${BAR}")
     self.d.setVar("BAR", "${${@'FOO'}}")
     value = bbvalue.bbvalue("FOO", self.d)
     self.assertRaises(bbvalue.RecursionError, str, value)
示例#7
0
 def test_indirect_recursion(self):
     self.d.setVar("FOO", "${BAR}")
     self.d.setVar("BAR", "${BAZ}")
     self.d.setVar("BAZ", "${FOO}")
     value = bbvalue.bbvalue("FOO", self.d)
     self.assertRaises(bbvalue.RecursionError, str, value)
示例#8
0
 def test_double_reference(self):
     self.d.setVar("BAR", "bar value")
     self.d.setVar("FOO", "${BAR} foo ${BAR}")
     val = bbvalue.bbvalue("FOO", self.d)
     self.assertEqual(str(val), "bar value foo bar value")
示例#9
0
 def test_python_snippet_error_path(self):
     self.d.setVar("FOO", "foo value ${BAR}")
     self.d.setVar("BAR", "bar value ${@int('test')}")
     val = bbvalue.bbvalue("FOO", self.d)
     self.assertRaises(bbvalue.PythonExpansionError, val.resolve)
示例#10
0
 def test_python_snippet_runtime_error(self):
     self.d.setVar("FOO", "${@int('test')}")
     val = bbvalue.bbvalue("FOO", self.d)
     self.assertRaises(bbvalue.PythonExpansionError, val.resolve)
示例#11
0
 def test_python_snippet_syntax_error(self):
     self.d.setVar("FOO", "${@foo = 5}")
     val = bbvalue.bbvalue("FOO", self.d)
     self.assertRaises(SyntaxError, val.resolve)
示例#12
0
 def test_false_condition(self):
     value = bbvalue.Conditional(self.metadata,
                                 lambda d: 'foo' in d.getVar("OVERRIDES", True).split(":"),
                                 [bbvalue.bbvalue("TEST", self.metadata)])
     self.metadata.setVar("OVERRIDES", "bar:local")
     self.assertEqual(value.resolve(), "")
示例#13
0
 def test_nonstring(self):
     self.d.setVar("TEST", 5)
     val = bbvalue.bbvalue("TEST", self.d)
     self.assertEqual(str(val), "5")
示例#14
0
 def test_append(self):
     value = bbvalue.LazyCompound(self.metadata)
     value.append(bbvalue.bbvalue("VAL", self.metadata))
     value.lazy_append(bbvalue.bbparse(":${BAR}", self.metadata))
     self.assertEqual(value.resolve(), "val:bar")
示例#15
0
 def test_prepend(self):
     value = bbvalue.LazyCompound(self.metadata)
     value.append(bbvalue.bbvalue("VAL", self.metadata))
     value.lazy_prepend(bbvalue.bbparse("${FOO}:", self.metadata))
     self.assertEqual(value.resolve(), "foo:val")
示例#16
0
 def test_same_value(self):
     d = bb.data.init()
     d.setVar("foo", "value of")
     d.setVar("bar", "value of")
     self.assertEqual(bbvalue.bbvalue("foo", d),
                      bbvalue.bbvalue("bar", d))
示例#17
0
 def test_memoized(self):
     d = bb.data.init()
     d.setVar("FOO", "bar")
     self.assertTrue(bbvalue.bbvalue("FOO", d) is
                     bbvalue.bbvalue("FOO", d))
示例#18
0
 def test_no_condition(self):
     value = bbvalue.Conditional(self.metadata, None,
                                 [bbvalue.bbvalue("TEST", self.metadata)])
     self.assertEqual(value.resolve(), "testvalue")
示例#19
0
def references_from_name(varname, metadata):
    refs = references(bbvalue.bbvalue(varname, metadata), metadata)
    refs |= references_from_flags(varname, metadata)
    return refs