Exemplo n.º 1
0
    def testGenerateSourceFileNoPchSystemIncludes(self):
        """
        Tests that the method
        module_sources.JumboCompileUnit.generateSourceFile()
        generates a jumbo-compile unit as expected.
        """
        u = module_sources.JumboCompileUnit(type='tests',
                                            module='foo',
                                            name='src/foo_jumbo.cpp',
                                            pch=False,
                                            system_includes=True)
        u.addSourceFile('src/foo_bar.cpp')
        u.addSourceFile('src/foo_baz.cpp')
        # first call writes the jumbo-compile-unit
        self.assertTrue(
            u.generateSourceFile(self.sourceRoot(), self.sourceRoot()))
        # second call doesn't change it
        self.assertFalse(
            u.generateSourceFile(self.sourceRoot(), self.sourceRoot()))

        jumbo_file = os.path.join(self.moduleDir(), 'src', 'foo_jumbo.cpp')
        self.assertTrue(os.path.exists(jumbo_file))
        f = open(jumbo_file, 'r')
        jumbo_content = f.read()
        f.close()
        os.remove(jumbo_file)
        self.assertTrue(
            "#include \"core/pch_system_includes.h\"" in jumbo_content)
        self.assertTrue(
            "#include \"tests/foo/src/foo_bar.cpp\"" in jumbo_content)
        self.assertTrue(
            "#include \"tests/foo/src/foo_baz.cpp\"" in jumbo_content)
Exemplo n.º 2
0
 def testGetModuleDir(self):
     u = module_sources.JumboCompileUnit(type="modules",
                                         module="my_module",
                                         name="my_module_jumbo.cpp",
                                         pch=True,
                                         system_includes=False)
     self.assertEqual(u.getModuleDir(),
                      os.path.join("modules", "my_module"))
     u = module_sources.JumboCompileUnit(type="modules",
                                         module="foo/bar/my_sub_module",
                                         name="my_module_jumbo.cpp",
                                         pch=True,
                                         system_includes=False)
     self.assertEqual(
         u.getModuleDir(),
         os.path.join("modules", "foo", "bar", "my_sub_module"))
Exemplo n.º 3
0
 def testGetFilepath(self):
     """
     Tests that module_sources.JumboCompileUnit.getFilepath()
     returns the correct path to the jumbo compile unit with the
     platform's path separator.
     """
     u = module_sources.JumboCompileUnit(type='modules',
                                         module='foo',
                                         name='src/foo_jumbo.cpp',
                                         pch=True,
                                         system_includes=False)
     self.assertEqual(
         u.getFilepath(),
         os.path.join('modules', 'foo', 'src', 'foo_jumbo.cpp'))
     u = module_sources.JumboCompileUnit(type="modules",
                                         module="foo/bar/my_sub_module",
                                         name="my_module_jumbo.cpp",
                                         pch=True,
                                         system_includes=False)
     self.assertEqual(
         u.getFilepath(),
         os.path.join("modules", "foo", "bar", "my_sub_module",
                      "my_module_jumbo.cpp"))