self.csig = csig
def get_csig(self):
- return self.bsig
+ return self.csig
def get_prevsiginfo(self):
return (self.oldtime, self.oldbsig, self.oldcsig)
self.test_built()
self.test_modify()
self.test_delete()
+ self.test_cache()
def test_initial(self):
self.failUnless(current(calc, nodes[8]))
self.failUnless(not current(calc, nodes[9]), "deleted")
self.failUnless(current(calc, nodes[10]),
- "current even though its source was deleted")
+ "current even though its source was deleted")
+
+ def test_cache(self):
+ """Test that signatures are cached properly."""
+ nodes = create_nodes(self.files)
+
+ calc = SCons.Sig.Calculator(self.module)
+ nodes[0].set_csig(1)
+ nodes[1].set_bsig(1)
+ assert calc.csig(nodes[0]) == 1, calc.csig(nodes[0])
+ assert calc.bsig(nodes[1]) == 1, calc.bsig(nodes[1])
+
class MD5TestCase(unittest.TestCase, SigTestBase):
"""Test MD5 signatures"""
#XXX If configured, use the content signatures from the
#XXX .sconsign file if the timestamps match.
+ bsig = node.get_bsig()
+ if not bsig is None:
+ return bsig
+
# Collect the signatures for ALL the nodes that this
# node depends on. Just collecting the direct
# dependants is not good enough, because
# not include the signatures of its psuedo-sources
# (e.g. the signature for a .c file does not include
# the signatures of the .h files that it includes).
- walker = SCons.Node.Walker(node)
+
+ # However, we do NOT want to walk dependencies of non-
+ # derived files, because calling get_signature() on the
+ # derived nodes will in turn call bsig() again and do that
+ # for us. Hence:
+ def walk_non_derived(n, myself=node):
+ if not n.builder or n is myself:
+ return n.children()
+ return []
+ walker = SCons.Node.Walker(node, walk_non_derived)
sigs = []
while 1:
child = walker.next()
return None
#XXX If configured, use the content signatures from the
#XXX .sconsign file if the timestamps match.
+ csig = node.get_csig()
+ if not csig is None:
+ return csig
+
return self.module.signature(node)
def get_signature(self, node):