Exemplo n.º 1
0
    def test_similar_includes(self):
        brls = {
            'smpso_cpp': 'dummy/jmetal/algorithms/smpso/smpso.cpp',
            'smpso_h': 'dummy/jmetal/algorithms/smpso/smpso.h',
            'pso_settings_cpp': 'dummy/jmetal/settings/pso_settings.cpp',
            'pso_settings_h': 'dummy/jmetal/settings/pso_settings.h',
            'pso_cpp': 'dummy/jmetal/algorithms/pso/pso.cpp',
            'pso_h': 'dummy/jmetal/algorithms/pso/pso.h',
            'pso_main': 'dummy/jmetal/main/pso_main.cpp',
        }
        cells = {x: SimpleCell(x) for x in brls.values()}
        cells_names = [x.name.cell_name for x in cells.itervalues()]
        block_holder = self._cells_setup('dummy/jmetal', cells_names, CPP)

        smpso_cpp = block_holder['algorithms/smpso/smpso.cpp'].cell
        pso_cpp = block_holder['algorithms/pso/pso.cpp'].cell
        pso_settings_h = block_holder['settings/pso_settings.h'].cell
        pso_main = block_holder['main/pso_main.cpp'].cell

        smpso_cpp.dependencies.unresolved = {CPPDeclaration('smpso.h')}
        pso_cpp.dependencies.unresolved = {CPPDeclaration('pso.h')}
        pso_settings_h.dependencies.unresolved = {
            CPPDeclaration('../algorithms/pso/pso.h')
        }
        pso_main.dependencies.unresolved = {
            CPPDeclaration('../algorithms/pso/pso.h')
        }

        process_holder(block_holder, DependenciesProcessor())
        # Checks
        self.assertEquals(set(), pso_cpp.dependencies.unresolved)
        self.assertEquals(set(), smpso_cpp.dependencies.unresolved)
        self.assertEquals(set(), pso_settings_h.dependencies.unresolved)
        self.assertEquals(set(), pso_main.dependencies.unresolved)
    def simple_dependencies_node_test(self):
        block_holder = self._cells_setup('dummy/geom',
                                   ['spherefun.js', 'sphere.js', 'main.js', 'other.js'],
                                   JS)
        # Parse processor setup

        block_holder['main.js'].cell.dependencies.unresolved = {NodeDeclaration('http.js'),
                                                           NodeDeclaration('./sphere.js'),
                                                           NodeDeclaration('other.js')}
        block_holder['sphere.js'].cell.dependencies.unresolved = {NodeDeclaration('http.js'),
                                                             NodeDeclaration('url.js'),
                                                             NodeDeclaration('./spherefun.js')}
        process_holder(block_holder, DependenciesProcessor())

        # Checks
        mainR = block_holder['main.js'].cell
        self.assertEqual(mainR.dependencies.explicit, {'dummy/geom/sphere.js'})
        self.assertEqual(mainR.dependencies.system, {'http.js'})
        self.assertEqual(mainR.dependencies.resolved,
                         {NodeDeclaration('http.js'), NodeDeclaration('./sphere.js')})
        self.assertEqual(mainR.dependencies.unresolved, {NodeDeclaration('other.js')})

        sphereR = block_holder['sphere.js'].cell
        self.assertEqual(sphereR.dependencies.explicit, {'dummy/geom/spherefun.js'})
        self.assertEqual(sphereR.dependencies.system, {'http.js', 'url.js'})
        self.assertEqual(sphereR.dependencies.resolved, {NodeDeclaration('http.js'),
                                                         NodeDeclaration('url.js'),
                                                         NodeDeclaration('./spherefun.js')})
        self.assertEqual(sphereR.dependencies.unresolved, set())
Exemplo n.º 3
0
    def test_duplicated_n_level(self):
        brls = {
            'gtest1': 'dummy/block/a1/b/c/gtest/gtest.h',
            'getest2': 'dummy/block/a2/gtest/gtest.h',
            'getest-all1': 'dummy/block/a1/gtest-all.cc',
            'getest-all2': 'dummy/block/a3/gtest-all.cc',
            'getest-all3': 'dummy/block/a1/b2/gtest-all.cc',
        }
        cells = {x: SimpleCell(x) for x in brls.values()}
        cells_names = [x.name.cell_name for x in cells.itervalues()]
        block_holder = self._cells_setup('dummy/block', cells_names, CPP)

        getest_all1 = block_holder['a1/gtest-all.cc'].cell
        getest_all1.dependencies.unresolved = {
            CPPDeclaration('b/c/gtest/gtest.h')
        }
        getest_all2 = block_holder['a3/gtest-all.cc'].cell
        getest_all2.dependencies.unresolved = {CPPDeclaration('gtest.h')}
        getest_all3 = block_holder['a1/b2/gtest-all.cc'].cell
        getest_all3.dependencies.unresolved = {
            CPPDeclaration('../b/c/gtest/gtest.h')
        }
        process_holder(block_holder, DependenciesProcessor())
        # Checks
        self.assertEquals(0, len(getest_all1.dependencies.unresolved))
        self.assertEquals(1, len(getest_all2.dependencies.unresolved))
        self.assertEquals(0, len(getest_all3.dependencies.unresolved))
Exemplo n.º 4
0
    def virtual_dependencies_test(self):
        sphereh = 'dummy/geom/sphere.h'
        sphereh_test = 'dummy/geom/test/sphere.h'
        sphereh_dev = 'dummy/geom/develop/sphere.h'

        block_holder = self._cells_setup(
            'dummy/geom',
            ['main.cpp', 'test/sphere.h', 'main2.cpp', 'develop/sphere.h'],
            CPP)
        block_holder._resources['sphere.h'] = Resource(VirtualCell(sphereh),
                                                       None)
        block_holder['test/sphere.h'].cell.container = BlockCellName(sphereh)
        block_holder['develop/sphere.h'].cell.container = BlockCellName(
            sphereh)
        block_holder['main.cpp'].cell.dependencies.unresolved = {
            CPPDeclaration(sphereh_test)
        }
        block_holder['main2.cpp'].cell.dependencies.unresolved = {
            CPPDeclaration(sphereh_dev)
        }
        _, outputstream = process_holder(block_holder, DependenciesProcessor())
        warn = 'Block dummy/geom has absolute paths, like: #include "dummy/geom/develop/sphere.h"'
        self.assertIn(warn, str(outputstream))

        # Checks
        main_cell = block_holder['main.cpp'].cell
        self.check_dependency_set(main_cell.dependencies,
                                  resolved=[sphereh_test],
                                  explicit=[sphereh])
        main_cell = block_holder['main2.cpp'].cell
        self.check_dependency_set(main_cell.dependencies,
                                  resolved=[sphereh_dev],
                                  explicit=[sphereh])
Exemplo n.º 5
0
    def test_include_partial(self):
        brls = {
            'main': 'dummy/block/main.cpp',
            'astar': 'dummy/block/algorithms/astar.h',
            'solver_h': 'dummy/block/solver/solver.h',
            'solver_cpp': 'dummy/block/solver/solver.cpp'
        }
        cells = {x: SimpleCell(x) for x in brls.values()}
        cells_names = [x.name.cell_name for x in cells.itervalues()]
        block_holder = self._cells_setup('dummy/block', cells_names, CPP)

        main = block_holder['main.cpp'].cell
        main.dependencies.unresolved = {CPPDeclaration('solver/solver.h')}
        solver_h = block_holder['solver/solver.h'].cell
        solver_h.dependencies.unresolved = {
            CPPDeclaration('../algorithms/astar.h')
        }
        solver_cpp = block_holder['solver/solver.cpp'].cell
        solver_cpp.dependencies.unresolved = {CPPDeclaration('solver.h')}

        process_holder(block_holder, DependenciesProcessor())
        # Checks
        self.assertEquals(set(), cells[brls['main']].dependencies.unresolved)
        self.assertEquals(set(),
                          cells[brls['solver_h']].dependencies.unresolved)
        self.assertEquals(set(),
                          cells[brls['solver_cpp']].dependencies.unresolved)
Exemplo n.º 6
0
    def simple_dependencies_cpp_test(self):
        block_holder = self._cells_setup(
            'dummy/geom', ['sphere.h', 'sphere.cpp', 'main.cpp'], CPP)
        # Parse processor setup

        block_holder['main.cpp'].cell.dependencies.unresolved = {
            CPPDeclaration('iostream'),
            CPPDeclaration('sphere.h')
        }
        block_holder['sphere.cpp'].cell.dependencies.unresolved = {
            CPPDeclaration('math.h'),
            CPPDeclaration('iostream'),
            CPPDeclaration('sphere.h')
        }
        changes, _ = process_holder(block_holder, DependenciesProcessor())
        # Checks
        self.assert_bii_equal(changes, ProcessorChanges())
        mainR = block_holder['main.cpp'].cell
        self.check_dependency_set(mainR.dependencies,
                                  resolved=['sphere.h', 'iostream'],
                                  explicit=['dummy/geom/sphere.h'],
                                  system=['iostream'])

        sphereR = block_holder['sphere.cpp'].cell
        self.check_dependency_set(sphereR.dependencies,
                                  resolved=['sphere.h', 'iostream', 'math.h'],
                                  explicit=['dummy/geom/sphere.h'],
                                  system=['iostream', 'math.h'])
Exemplo n.º 7
0
    def __init__(self, active_langs):
        self.processors = [ParseProcessor(), VirtualConfigurationProcessor()]

        self.processors.append(DependenciesProcessor())
        self.processors.append(
            CPPImplementationsProcessor())  # The order is important
        self.processors.append(DependenciesConfigurationProcessor())
        if 'arduino' in active_langs:
            self.processors.append(ArduinoEntryPointProcesor())
        # This should be the last one to process mains as it can disable entry points
        self.processors.append(MainConfigProcessor())
Exemplo n.º 8
0
    def not_delete_dependant_test(self):
        """ A resolved dependency in the same block must NOT be removed if that exist """
        sphereh = 'dummy/geom/sphere.h'
        block_holder = self._cells_setup('dummy/geom', ['main.cpp', 'sphere.h'], CPP)

        main_cell = block_holder['main.cpp'].cell
        main_cell.dependencies.explicit = {BlockCellName(sphereh)}
        main_cell.dependencies.system = {SystemCellName('iostream')}
        main_cell.dependencies.resolved = {CPPDeclaration('sphere.h'), CPPDeclaration('iostream')}
        process_holder(block_holder, DependenciesProcessor())
        # Checks
        self.check_dependency_set(main_cell.dependencies, resolved=['sphere.h', 'iostream'],
                                   explicit=[sphereh], system=['iostream'])
Exemplo n.º 9
0
    def test_duplicated_first_level(self):
        brls = {'gtest1': 'dummy/block/include/gtest/gtest.h',
                'getest2': 'dummy/block/fused-src/gtest/gtest.h',
                'getest-all1': 'dummy/block/fused-src/gtest/gtest-all.cc',
                'getest-all2': 'dummy/block/src/gtest-all.cc',
                'sample': 'dummy/block/samples/sample_unittest.cc'
                }
        cells = {x: SimpleCell(x) for x in brls.values()}
        cells_names = [x.name.cell_name for x in cells.itervalues()]
        block_holder = self._cells_setup('dummy/block', cells_names, CPP)

        getest_all1 = block_holder['fused-src/gtest/gtest-all.cc'].cell
        getest_all1.dependencies.unresolved = {CPPDeclaration('gtest.h')}
        getest_all2 = block_holder['src/gtest-all.cc'].cell
        getest_all2.dependencies.unresolved = {CPPDeclaration('gtest.h')}
        sample = block_holder['samples/sample_unittest.cc'].cell
        sample.dependencies.unresolved = {CPPDeclaration('gtest.h')}
        process_holder(block_holder, DependenciesProcessor())
        # Checks
        self.assertEquals(0, len(getest_all1.dependencies.unresolved))
        self.assertEquals(1, len(getest_all2.dependencies.unresolved))
        self.assertEquals(1, len(sample.dependencies.unresolved))