def test7(self): # bad # / # / # / # root ----------- good1 # \ ----- yields good1, good2 (good1 is seen through good2, # \ / but is a direct successor of root) # \ / # good2 # ----- root = Node(Node.BAD) bad = Node(Node.BAD) good1 = Node(Node.GOOD) good2 = Node(Node.GOOD) digraph = DirectedGraph(nodes=[root, bad, good1, good2], edges=[ Edge(root, bad), Edge(root, good1), Edge(root, good2), Edge(good2, good1) ]) self.failUnlessEqual( set([good1, good2]), algorithm.nearest_property(digraph=digraph, entrypoint=root, property=GoodProperty())) pass
def test1(self): # bad1 # / \ # root / good yields good # \ /---- # \ / # bad2 root = Node(Node.BAD) bad1 = Node(Node.BAD) bad2 = Node(Node.BAD) good = Node(Node.GOOD) digraph = DirectedGraph(nodes=[root, bad1, bad2, good], edges=[ Edge(tail=root, head=bad1), Edge(tail=root, head=bad2), Edge(tail=bad1, head=good), Edge(tail=bad2, head=good) ]) self.failUnlessEqual( set([good]), algorithm.nearest_property(digraph=digraph, entrypoint=root, property=GoodProperty())) pass
def test6(self): # bad # / \ # / \ # root good2 # \ ----- yields good1, good2 # \ # good1 # ----- root = Node(Node.BAD) bad = Node(Node.BAD) good1 = Node(Node.GOOD) good2 = Node(Node.GOOD) digraph = DirectedGraph( nodes=[root, bad, good1, good2], edges=[Edge(root, bad), Edge(root, good1), Edge(bad, good2)]) self.failUnlessEqual( set([good1, good2]), algorithm.nearest_property(digraph=digraph, entrypoint=root, property=GoodProperty())) pass
def test3(self): # good1 --- good3 # / ----- ----- # bad1 / # / \ yields good1, good2 # root / \ good2 # \ /----- # \ / # bad2 / root = Node(Node.BAD) bad1 = Node(Node.BAD) bad2 = Node(Node.BAD) good1 = Node(Node.GOOD) good2 = Node(Node.GOOD) good3 = Node(Node.GOOD) digraph = DirectedGraph(nodes=[root, bad1, bad2, good1, good2, good3], edges=[ Edge(root, bad1), Edge(root, bad2), Edge(bad1, good1), Edge(bad1, good2), Edge(bad2, good2), Edge(good1, good3) ]) self.failUnlessEqual( set([good1, good2]), algorithm.nearest_property(digraph=digraph, entrypoint=root, property=GoodProperty())) pass
def relate(self, node, digraph, topolist): """ Builder method. As a service (we do not do anthing meaningful with the information ourselves), we remember both the topologically sorted list of the libraries that we depend on, as well as the libraries that we directly depend on. """ Builder.relate(self, node, digraph, topolist) self.__buildinfo_topo_dependent_native_libs = [] self.__buildinfo_direct_dependent_native_libs = [] nodes_with_library = algorithm.nearest_property(digraph=digraph, entrypoint=node, property=self.HaveLibraryProperty()) for n in nodes_with_library: for bi in n.iter_buildinfos(): if type(bi) in (BuildInfo_CLibrary_NativeLocal, BuildInfo_CLibrary_NativeInstalled): self.__buildinfo_direct_dependent_native_libs.append(bi) pass pass pass for n in topolist: for bi in n.iter_buildinfos(): if type(bi) in (BuildInfo_CLibrary_NativeLocal, BuildInfo_CLibrary_NativeInstalled): self.__buildinfo_topo_dependent_native_libs.insert(0, bi) pass pass pass pass
def test0(self): # root ---- bad yields [] root = Node(Node.BAD) bad = Node(Node.BAD) digraph = DirectedGraph(nodes=[root, bad], edges=[Edge(root, bad)]) self.failUnlessEqual( set(), algorithm.nearest_property(digraph=digraph, entrypoint=root, property=GoodProperty())) pass
def test8(self): # root --- good1 --- good2 yields good1 root = Node(Node.BAD) good1 = Node(Node.GOOD) good2 = Node(Node.GOOD) digraph = DirectedGraph(nodes=[root, good1, good2], edges=[Edge(root, good1), Edge(good1, good2)]) self.failUnlessEqual( set([good1]), algorithm.nearest_property(digraph=digraph, entrypoint=root, property=GoodProperty())) pass
def test2(self): # bad # / \ # root /______\ good yields good # ---- root = Node(Node.BAD) bad = Node(Node.BAD) good = Node(Node.GOOD) digraph = DirectedGraph( nodes=[root, bad, good], edges=[Edge(root, bad), Edge(root, good), Edge(bad, good)]) self.failUnlessEqual( set([good]), algorithm.nearest_property(digraph=digraph, entrypoint=root, property=GoodProperty())) pass