def test(self):
     fconfig = parser.file_configuration_t( data=self.__fname
                 , content_type=parser.CONTENT_TYPE.CACHED_SOURCE_FILE )
     try:
         prj_reader = parser.project_reader_t( self.config )
         prj_decls = prj_reader.read_files( [fconfig]
                                            , compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE )
         self.failUnless( os.path.exists( fconfig.cached_source_file ) )
         mtime1 = os.stat(fconfig.cached_source_file)[stat.ST_MTIME] 
         prj_decls = prj_reader.read_files( [fconfig]
                                            , compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE )
         mtime2 = os.stat(fconfig.cached_source_file)[stat.ST_MTIME] 
         self.failUnless( mtime1 == mtime2 )
     finally:
         utils.remove_file_no_raise( fconfig.cached_source_file )
Exemple #2
0
 def test(self):
     fconfig = parser.file_configuration_t(
         data=self.__fname,
         content_type=parser.CONTENT_TYPE.CACHED_SOURCE_FILE)
     try:
         prj_reader = parser.project_reader_t(self.config)
         prj_reader.read_files(
             [fconfig],
             compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
         self.assertTrue(os.path.exists(fconfig.cached_source_file))
         mtime1 = os.stat(fconfig.cached_source_file)[stat.ST_MTIME]
         prj_reader.read_files(
             [fconfig],
             compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE)
         mtime2 = os.stat(fconfig.cached_source_file)[stat.ST_MTIME]
         self.assertTrue(mtime1 == mtime2)
     finally:
         utils.remove_file_no_raise(fconfig.cached_source_file, self.config)
    def test(self):
        src_reader = parser.source_reader_t( self.config )
        src_decls = src_reader.read_file( self.__fname )        

        xmlfile = src_reader.create_xml_file( self.__fname )
        try:
            fconfig = parser.file_configuration_t( data=xmlfile
                                                   , start_with_declarations=None
                                                   , content_type=parser.file_configuration_t.CONTENT_TYPE.GCCXML_GENERATED_FILE )
            
            prj_reader = parser.project_reader_t( self.config )
            prj_decls = prj_reader.read_files( [fconfig]
                                               , compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE )
            
            self.failUnless( src_decls == prj_decls
                             , "There is a difference between declarations in file %s." % self.__fname )
        finally:
            utils.remove_file_no_raise( xmlfile )
Exemple #4
0
    def test(self):
        src_reader = parser.source_reader_t( self.config )
        src_decls = src_reader.read_file( self.__fname )        

        xmlfile = src_reader.create_xml_file( self.__fname )
        try:
            fconfig = parser.file_configuration_t( data=xmlfile
                                                   , start_with_declarations=None
                                                   , content_type=parser.file_configuration_t.CONTENT_TYPE.GCCXML_GENERATED_FILE )
            
            prj_reader = parser.project_reader_t( self.config )
            prj_decls = prj_reader.read_files( [fconfig]
                                               , compilation_mode=parser.COMPILATION_MODE.FILE_BY_FILE )
            
            self.failUnless( src_decls == prj_decls
                             , "There is a difference between declarations in file %s." % self.__fname )
        finally:
            utils.remove_file_no_raise( xmlfile )
Exemple #5
0
    def read_xml( self, file_configuration ):
        """parses C++ code, defined on the file_configurations and returns GCCXML
        generated file content"""

        xml_file_path = None
        delete_xml_file = True
        fc = file_configuration
        reader = source_reader.source_reader_t( self.__config, None, self.__decl_factory )
        try:
            if fc.content_type == fc.CONTENT_TYPE.STANDARD_SOURCE_FILE:
                self.logger.info( 'Parsing source file "%s" ... ' % fc.data )
                xml_file_path = reader.create_xml_file( fc.data )
            elif fc.content_type == file_configuration_t.CONTENT_TYPE.GCCXML_GENERATED_FILE:
                self.logger.info( 'Parsing xml file "%s" ... ' % fc.data )
                xml_file_path = fc.data
                delete_xml_file = False
            elif fc.content_type == fc.CONTENT_TYPE.CACHED_SOURCE_FILE:
                #TODO: raise error when header file does not exist
                if not os.path.exists( fc.cached_source_file ):
                    dir_ = os.path.split( fc.cached_source_file )[0]
                    if dir_ and not os.path.exists( dir_ ):
                        os.makedirs( dir_ )
                    self.logger.info( 'Creating xml file "%s" from source file "%s" ... '
                                      % ( fc.cached_source_file, fc.data ) )
                    xml_file_path = reader.create_xml_file( fc.data, fc.cached_source_file )
                else:
                    xml_file_path = fc.cached_source_file
            else:
                xml_file_path = reader.create_xml_file_from_string( fc.data )
            xml_file = file( xml_file_path, 'r' )
            xml = xml_file.read()
            xml_file.close()
            utils.remove_file_no_raise( xml_file_path )
            return xml
        finally:
            if xml_file_path and delete_xml_file:
                utils.remove_file_no_raise( xml_file_path )