Beispiel #1
0
 def __init__(self, policy=None):
     self.unresolved = set()  # Unresolved declarations to be found
     self.block_names = set()  # Current hive src blocks, to forbid cycles
     self.existing = ReferencedDependencies()  # Current resolved deps
     self.existing_common_table = BlockVersionTable()
     self.policy = policy
     self.find = True  # To find for UNRESOLVED
     self.update = False  # To activate UPDATES
     self.downgrade = False  # To activate DOWNGRADES
     self.modify = False  # Allow changing deps to non-descendant branches
Beispiel #2
0
 def build_update_request(self, block_version, block_cell_name):
     request = FinderRequest()
     existing = ReferencedDependencies()
     existing[block_version][CPPDeclaration(block_cell_name)].add(
         block_cell_name)
     request.existing = existing
     request.policy = Policy.default()
     request.find = False
     request.update = True
     return request
Beispiel #3
0
    def check_result(self,
                     result,
                     resolved=None,
                     unresolved=None,
                     updated=None):
        unresolved = unresolved or []
        unresolved = {CPPDeclaration(str(u)) for u in unresolved}
        self.assertEqual(result.unresolved, unresolved)

        resolved = resolved or []
        refs = ReferencedDependencies()
        for brl, time, block_cell_names in resolved:
            for name in block_cell_names:
                refs[BlockVersion(
                    brl, time)][CPPDeclaration(name)] = {BlockCellName(name)}
        self.assertEqual(result.resolved, refs)

        updated = updated or []
        refs = ReferencedDependencies()
        for brl, time, block_cell_names in updated:
            for name in block_cell_names:
                refs[BlockVersion(
                    brl, time)][CPPDeclaration(name)] = {BlockCellName(name)}
        self.assertEqual(result.updated, refs)
    def test_fiunder_request_existing(self):
        f = FinderRequest()
        self.assertFalse(f)
        existing = ReferencedDependencies()
        version = BlockVersion('user/user/block/master', 1)
        existing[version][CPPDeclaration("file.h")].add(CellName("file.h"))
        f.existing = existing
        f.update = True
        f.policy = Policy.default()
        #print f
        s = f.serialize()
        #print s
        f2 = FinderRequest.deserialize(s)

        self.assertEquals(f, f2)
        self.assertTrue(f2)
Beispiel #5
0
 def external_dependencies(self):
     result = ReferencedDependencies()
     blocks = self.blocks
     for block_holder in self.block_holders:
         dep_table = block_holder.requirements
         for block_name, version in dep_table.iteritems():
             if block_name not in blocks:
                 result[version]  # defaultdict will create empty item
         for resource in block_holder.simple_resources:
             cell = resource.cell
             for declaration in cell.dependencies.resolved:
                 targets = declaration.match(cell.dependencies.explicit)
                 if targets:
                     block = declaration.block()
                     if block not in blocks:
                         block_version = dep_table[block]
                         result[block_version][declaration].update(targets)
     return result
Beispiel #6
0
    def test_apply_result(self):
        # TODO: this is actually a test of find result, move away
        files = {
            self.block_name + 'main.cpp': '#include "user2/block/sphere.h"'
        }
        self.hive_manager.process(None, files)

        find_result = FinderResult()
        version = BRLBlock('user2/user2/block/branch') + 3
        d = ReferencedDependencies()
        decl = CPPDeclaration('user2/block/sphere.h')
        d[version][decl].add(BlockCellName('user2/block/sphere.h'))
        find_result.resolved = d

        hive_holder = self.hive_manager.hive_holder
        update_hive_with_find_result(hive_holder, find_result)

        self.assertEqual(2, len(hive_holder.resources))
        self.assertEqual(BlockVersionTable([version]),
                         hive_holder[self.block_name].requirements)
Beispiel #7
0
 def __init__(self):
     self.resolved = ReferencedDependencies()
     self.unresolved = set()
     self.updated = ReferencedDependencies()