def test_find_two_files_at_a_time(self): """Starts with one include, finds it, then two more includes, finish when all are found. Found items are taken into account in FindRequest.existing """ NUM_FILES = 10 brl_a = BRLBlock('%s/%s/%s/master' % (self.user, self.user, 'blocka')) names_a = [ BlockCellName(self.user + "/blocka/a%d.h" % i) for i in range(NUM_FILES) ] resources_info = {"a%d.h" % i: ("a", []) for i in range(NUM_FILES)} publisher = TestPublisher(self.user, self.store) publisher.publish(brl_a, resources_info) # Use the same request object, to accumulate existing (already found) files request = FinderRequest() request.policy = Policy.default() version = BlockVersion(brl_a, 0) # The version is always the same for i in range(0, NUM_FILES, 2): declaration1 = CPPDeclaration(names_a[i]) declaration2 = CPPDeclaration(names_a[i + 1]) request.unresolved = {declaration1, declaration2} result = self.service.find(request, BiiResponse()) self.check_result(result, resolved=[(brl_a, 0, {names_a[i], names_a[i + 1]})]) # The found one is added to the existing, for next iteration request.existing[version][declaration1] = {names_a[i]} request.existing[version][declaration2] = {names_a[i + 1]} self.assertEqual(len(request.existing[version]), i + 2)
def test_finder_request_unresolved(self): f = FinderRequest() f.unresolved = set([CPPDeclaration("iostream.h"), CPPDeclaration("math.h")]) f.policy = Policy.default() s = f.serialize() f2 = FinderRequest.deserialize(s) self.assertEqual(f, f2)
def test_find_two_files_at_a_time(self): """Starts with one include, finds it, then two more includes, finish when all are found. Found items are taken into account in FindRequest.existing """ NUM_FILES = 10 brl_a = BRLBlock('%s/%s/%s/master' % (self.user, self.user, 'blocka')) names_a = [BlockCellName(self.user + "/blocka/a%d.h" % i) for i in range(NUM_FILES)] resources_info = {"a%d.h" % i: ("a", []) for i in range(NUM_FILES)} publisher = TestPublisher(self.user, self.store) publisher.publish(brl_a, resources_info) # Use the same request object, to accumulate existing (already found) files request = FinderRequest() request.policy = Policy.default() version = BlockVersion(brl_a, 0) # The version is always the same for i in range(0, NUM_FILES, 2): declaration1 = CPPDeclaration(names_a[i]) declaration2 = CPPDeclaration(names_a[i + 1]) request.unresolved = {declaration1, declaration2} result = self.service.find(request, BiiResponse()) self.check_result(result, resolved=[(brl_a, 0, {names_a[i], names_a[i + 1]})]) # The found one is added to the existing, for next iteration request.existing[version][declaration1] = {names_a[i]} request.existing[version][declaration2] = {names_a[i + 1]} self.assertEqual(len(request.existing[version]), i + 2)
def _unresolvedDependencyRequest(self, unresolved_deps): request = FinderRequest() unresolved = set() for dep in unresolved_deps: unresolved.add(CPPDeclaration(dep)) request.unresolved = unresolved request.policy = Policy.default() return request
def test_finder_request_unresolved(self): f = FinderRequest() f.unresolved = set( [CPPDeclaration("iostream.h"), CPPDeclaration("math.h")]) f.policy = Policy.default() s = f.serialize() f2 = FinderRequest.deserialize(s) self.assertEqual(f, f2)
def build_unresolved_request(self, unresolved_deps): if isinstance(unresolved_deps, basestring): unresolved_deps = [unresolved_deps] request = FinderRequest() unresolved = set() for dep in unresolved_deps: unresolved.add(CPPDeclaration(dep)) request.unresolved = unresolved request.policy = Policy.default() return request
def find_request(self, policy): request = FinderRequest(policy) request.existing = self.external_dependencies() blocks = self.blocks # ONly those that have a block to be searched for unresolved = set() local_unresolved = set() for block_holder in self.block_holders: includes = block_holder.includes paths_size = len(block_holder.paths) for declaration in self.external_unresolved(): try: new_declaration, _ = declaration.prefix(includes, paths_size) except: new_declaration = declaration decl_block = new_declaration.block() if decl_block and decl_block not in blocks: unresolved.add(new_declaration) else: local_unresolved.add(new_declaration) request.unresolved = unresolved request.block_names = self.blocks return request, local_unresolved
def find_request(self, policy): request = FinderRequest(policy) request.existing = self.external_dependencies() blocks = self.blocks # ONly those that have a block to be searched for unresolved = set() local_unresolved = set() for block_holder in self.block_holders: includes = block_holder.includes paths_size = len(block_holder.paths) for declaration in self.external_unresolved(): try: new_declaration, _ = declaration.prefix( includes, paths_size) except: new_declaration = declaration decl_block = new_declaration.block() if decl_block and decl_block not in blocks: unresolved.add(new_declaration) else: local_unresolved.add(new_declaration) request.unresolved = unresolved request.block_names = self.blocks return request, local_unresolved