[pygccxml-commit] SF.net SVN: pygccxml:[1711] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-05-10 20:04:19
|
Revision: 1711 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1711&view=rev Author: roman_yakovenko Date: 2009-05-10 20:04:09 +0000 (Sun, 10 May 2009) Log Message: ----------- fixing unittests Modified Paths: -------------- pyplusplus_dev/pyplusplus/creators_factory/dependencies_manager.py pyplusplus_dev/unittests/fundamental_tester_base.py pyplusplus_dev/unittests/virtual_inheritance_tester.py Modified: pyplusplus_dev/pyplusplus/creators_factory/dependencies_manager.py =================================================================== --- pyplusplus_dev/pyplusplus/creators_factory/dependencies_manager.py 2009-05-10 18:25:05 UTC (rev 1710) +++ pyplusplus_dev/pyplusplus/creators_factory/dependencies_manager.py 2009-05-10 20:04:09 UTC (rev 1711) @@ -1,203 +1,206 @@ -# Copyright 2004-2008 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -"""defines class, which informs user about used, but unexposed declarations""" - -import os -from pyplusplus import utils -from pyplusplus import messages -from pygccxml import declarations -from pyplusplus import decl_wrappers - -class duplicated_names_reporter_t(object): - def __init__( self, decls, value_getter, msg ): - self.decls = decls - self.get_value = value_getter - self.msg = msg - - def __select( self ): - duplicated = {} - for decl in self.decls: - value = self.get_value( decl ) - if not duplicated.has_key( value ): - duplicated[ value ] = set() - duplicated[ value ].add( decl ) - result = duplicated.copy() - for value, buggy_decls in duplicated.items(): - if 1 == len( buggy_decls ): - del result[ value ] - return result - - def __report_single( self, control_decl, duplicated, logger ): - value = self.get_value( control_decl ) - if value not in duplicated: - return - buggy_decls = duplicated[value].copy() - buggy_decls.remove( control_decl ) - warning = self.msg % ( value, os.linesep.join( map( str, buggy_decls ) ) ) - logger.warn( "%s;%s" % ( str( control_decl ), warning ) ) - - def report( self, logger ): - duplicated = self.__select() - for decl in self.decls: - self.__report_single( decl, duplicated, logger ) - -duplicated_aliases_reporter \ - = lambda decls: duplicated_names_reporter_t( decls, lambda d: d.alias, messages.W1047 ) - -duplicated_wrapper_aliases_reporter \ - = lambda decls: duplicated_names_reporter_t( decls, lambda d: d.wrapper_alias, messages.W1065 ) - - -class manager_t( object ): - def __init__( self, logger ): - object.__init__( self ) - self.__exported_decls = [] - self.__logger = logger - - def add_exported( self, decl ): - self.__exported_decls.append( decl ) - - def __is_std_decl( self, decl ): - #Every class under std should be exported by Boost.Python and\\or `Py++` - #Also this is not the case right now, I prefer to hide the warnings - dpath = declarations.declaration_path( decl ) - if len( dpath ) < 3: - return False - if dpath[1] != 'std': - return False - if decl.name.startswith( 'pair<' ): - #special case - return False - return True - - def __build_dependencies( self, decl ): - if self.__is_std_decl( decl ): - #TODO add element_type to the list of dependencies - return [] #std declarations should be exported by `Py++`! - if decl.already_exposed: - return [] - dependencies = decl.i_depend_on_them(recursive=False) - - if isinstance( decl, declarations.class_t ): - dependencies = filter( lambda d: d.access_type != declarations.ACCESS_TYPES.PRIVATE - , dependencies ) - - return dependencies - - def __has_unexposed_dependency( self, exported_ids, depend_on_decl, dependency ): - sptr_traits = declarations.smart_pointer_traits - - if None is depend_on_decl: - return - - if self.__is_std_decl( depend_on_decl ): - return - - if sptr_traits.is_smart_pointer( depend_on_decl ): - try: - value_type = sptr_traits.value_type( depend_on_decl ) - if isinstance( value_type, declarations.type_t ): - value_type = declarations.remove_cv( value_type ) - value_type = declarations.remove_declarated( value_type ) - if isinstance( value_type, declarations.declaration_t ): - return self.__has_unexposed_dependency( exported_ids, value_type, dependency ) - except RuntimeError: - pass - - if isinstance( depend_on_decl, decl_wrappers.decl_wrapper_t ): - if depend_on_decl.already_exposed: - return - if isinstance( depend_on_decl, declarations.class_types ): - if depend_on_decl.opaque: - return - if dependency.hint == "base class": - return #base class for some class don't have to be exported - if isinstance( depend_on_decl, declarations.variable_t ): - if not decl.expose_value: - return - - if isinstance( dependency.decl, declarations.variable_t ): - #the only dependency of the variable is its type - if not dependency.decl.expose_value: - return - - if dependency.hint == "return type": - #in this case we don't check, the return type but the function - if isinstance( dependency.decl, declarations.calldef_t ): - if dependency.decl.return_type and dependency.decl.call_policies \ - and decl_wrappers.is_return_opaque_pointer_policy( dependency.decl.call_policies ): - return - - return id( depend_on_decl ) not in exported_ids - - def __find_out_used_but_not_exported( self ): - used_not_exported = [] - exported_ids = set( map( lambda d: id( d ), self.__exported_decls ) ) - for decl in self.__exported_decls: - for dependency in self.__build_dependencies( decl ): - depend_on_decl = dependency.find_out_depend_on_declaration() - if self.__has_unexposed_dependency( exported_ids, depend_on_decl, dependency ): - if messages.filter_disabled_msgs([messages.W1040], depend_on_decl.disabled_messages ): - #need to report dependency errors - used_not_exported.append(dependency) - return used_not_exported - - def __group_by_unexposed( self, dependencies ): - groups = {} - for dependency in dependencies: - depend_on_decl = dependency.find_out_depend_on_declaration() - if not groups.has_key( id( depend_on_decl ) ): - groups[ id( depend_on_decl ) ] = [] - groups[ id( depend_on_decl ) ].append( dependency ) - return groups - - def __create_dependencies_msg( self, dependencies ): - depend_on_decl = dependencies[0].find_out_depend_on_declaration() - decls = [] - for dependency in dependencies: - decls.append( os.linesep + ' ' + str( dependency.declaration ) ) - return "%s;%s" % ( depend_on_decl, messages.W1040 % ''.join( decls ) ) - - def __report_duplicated_aliases( self ): - decls = filter( lambda decl: isinstance( decl, declarations.class_types ) \ - and isinstance( decl.parent, declarations.namespace_t ) - , self.__exported_decls ) - - dar = duplicated_aliases_reporter( decls ) - dar.report( self.__logger ) - - classes = filter( lambda c: isinstance( c, declarations.class_t ), decls ) - query = lambda decl: isinstance( decl, declarations.class_types ) \ - and decl.ignore == False \ - and decl._already_exposed == False - - for cls in classes: - internal_decls = cls.decls( query, recursive=False, allow_empty=True) - dar = duplicated_aliases_reporter( internal_decls ) - dar.report( self.__logger ) - - def __report_duplicated_wrapper_aliases( self ): - decls = filter( lambda decl: isinstance( decl, declarations.class_t ) \ - and isinstance( decl.parent, declarations.namespace_t ) - , self.__exported_decls ) - - dwar = duplicated_wrapper_aliases_reporter( decls ) - dwar.report( self.__logger ) - - query = lambda decl: decl.ignore == False and decl._already_exposed == False - - for cls in decls: - internal_decls = cls.classes( query, recursive=False, allow_empty=True) - dwar = duplicated_wrapper_aliases_reporter( internal_decls ) - dwar.report( self.__logger ) - - def inform_user( self ): - used_not_exported_decls = self.__find_out_used_but_not_exported() - groups = self.__group_by_unexposed( used_not_exported_decls ) - for group in groups.itervalues(): - self.__logger.warn( self.__create_dependencies_msg( group ) ) - self.__report_duplicated_aliases() - self.__report_duplicated_wrapper_aliases() +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +"""defines class, which informs user about used, but unexposed declarations""" + +import os +from pyplusplus import utils +from pyplusplus import messages +from pygccxml import declarations +from pyplusplus import decl_wrappers + +class duplicated_names_reporter_t(object): + def __init__( self, decls, value_getter, msg ): + self.decls = decls + self.get_value = value_getter + self.msg = msg + + def __select( self ): + duplicated = {} + for decl in self.decls: + value = self.get_value( decl ) + if not duplicated.has_key( value ): + duplicated[ value ] = set() + duplicated[ value ].add( decl ) + result = duplicated.copy() + for value, buggy_decls in duplicated.items(): + if 1 == len( buggy_decls ): + del result[ value ] + return result + + def __report_single( self, control_decl, duplicated, logger ): + value = self.get_value( control_decl ) + if value not in duplicated: + return + buggy_decls = duplicated[value].copy() + buggy_decls.remove( control_decl ) + warning = self.msg % ( value, os.linesep.join( map( str, buggy_decls ) ) ) + logger.warn( "%s;%s" % ( str( control_decl ), warning ) ) + + def report( self, logger ): + duplicated = self.__select() + for decl in self.decls: + self.__report_single( decl, duplicated, logger ) + +duplicated_aliases_reporter \ + = lambda decls: duplicated_names_reporter_t( decls, lambda d: d.alias, messages.W1047 ) + +duplicated_wrapper_aliases_reporter \ + = lambda decls: duplicated_names_reporter_t( decls, lambda d: d.wrapper_alias, messages.W1065 ) + + +class manager_t( object ): + def __init__( self, logger ): + object.__init__( self ) + self.__exported_decls = [] + self.__logger = logger + + def add_exported( self, decl ): + self.__exported_decls.append( decl ) + if isinstance( decl, declarations.class_t ) and decl.indexing_suite: + included_decls = decl.decls( lambda d: d.ignore==False, allow_empty=True, recursive=True ) + map( self.add_exported, included_decls ) + + def __is_std_decl( self, decl ): + #Every class under std should be exported by Boost.Python and\\or `Py++` + #Also this is not the case right now, I prefer to hide the warnings + dpath = declarations.declaration_path( decl ) + if len( dpath ) < 3: + return False + if dpath[1] != 'std': + return False + if decl.name.startswith( 'pair<' ): + #special case + return False + return True + + def __build_dependencies( self, decl ): + if self.__is_std_decl( decl ): + #TODO add element_type to the list of dependencies + return [] #std declarations should be exported by `Py++`! + if decl.already_exposed: + return [] + dependencies = decl.i_depend_on_them(recursive=False) + + if isinstance( decl, declarations.class_t ): + dependencies = filter( lambda d: d.access_type != declarations.ACCESS_TYPES.PRIVATE + , dependencies ) + + return dependencies + + def __has_unexposed_dependency( self, exported_ids, depend_on_decl, dependency ): + sptr_traits = declarations.smart_pointer_traits + + if None is depend_on_decl: + return + + if self.__is_std_decl( depend_on_decl ): + return + + if sptr_traits.is_smart_pointer( depend_on_decl ): + try: + value_type = sptr_traits.value_type( depend_on_decl ) + if isinstance( value_type, declarations.type_t ): + value_type = declarations.remove_cv( value_type ) + value_type = declarations.remove_declarated( value_type ) + if isinstance( value_type, declarations.declaration_t ): + return self.__has_unexposed_dependency( exported_ids, value_type, dependency ) + except RuntimeError: + pass + + if isinstance( depend_on_decl, decl_wrappers.decl_wrapper_t ): + if depend_on_decl.already_exposed: + return + if isinstance( depend_on_decl, declarations.class_types ): + if depend_on_decl.opaque: + return + if dependency.hint == "base class": + return #base class for some class don't have to be exported + if isinstance( depend_on_decl, declarations.variable_t ): + if not decl.expose_value: + return + + if isinstance( dependency.decl, declarations.variable_t ): + #the only dependency of the variable is its type + if not dependency.decl.expose_value: + return + + if dependency.hint == "return type": + #in this case we don't check, the return type but the function + if isinstance( dependency.decl, declarations.calldef_t ): + if dependency.decl.return_type and dependency.decl.call_policies \ + and decl_wrappers.is_return_opaque_pointer_policy( dependency.decl.call_policies ): + return + + return id( depend_on_decl ) not in exported_ids + + def __find_out_used_but_not_exported( self ): + used_not_exported = [] + exported_ids = set( map( lambda d: id( d ), self.__exported_decls ) ) + for decl in self.__exported_decls: + for dependency in self.__build_dependencies( decl ): + depend_on_decl = dependency.find_out_depend_on_declaration() + if self.__has_unexposed_dependency( exported_ids, depend_on_decl, dependency ): + if messages.filter_disabled_msgs([messages.W1040], depend_on_decl.disabled_messages ): + #need to report dependency errors + used_not_exported.append(dependency) + return used_not_exported + + def __group_by_unexposed( self, dependencies ): + groups = {} + for dependency in dependencies: + depend_on_decl = dependency.find_out_depend_on_declaration() + if not groups.has_key( id( depend_on_decl ) ): + groups[ id( depend_on_decl ) ] = [] + groups[ id( depend_on_decl ) ].append( dependency ) + return groups + + def __create_dependencies_msg( self, dependencies ): + depend_on_decl = dependencies[0].find_out_depend_on_declaration() + decls = [] + for dependency in dependencies: + decls.append( os.linesep + ' ' + str( dependency.declaration ) ) + return "%s;%s" % ( depend_on_decl, messages.W1040 % ''.join( decls ) ) + + def __report_duplicated_aliases( self ): + decls = filter( lambda decl: isinstance( decl, declarations.class_types ) \ + and isinstance( decl.parent, declarations.namespace_t ) + , self.__exported_decls ) + + dar = duplicated_aliases_reporter( decls ) + dar.report( self.__logger ) + + classes = filter( lambda c: isinstance( c, declarations.class_t ), decls ) + query = lambda decl: isinstance( decl, declarations.class_types ) \ + and decl.ignore == False \ + and decl._already_exposed == False + + for cls in classes: + internal_decls = cls.decls( query, recursive=False, allow_empty=True) + dar = duplicated_aliases_reporter( internal_decls ) + dar.report( self.__logger ) + + def __report_duplicated_wrapper_aliases( self ): + decls = filter( lambda decl: isinstance( decl, declarations.class_t ) \ + and isinstance( decl.parent, declarations.namespace_t ) + , self.__exported_decls ) + + dwar = duplicated_wrapper_aliases_reporter( decls ) + dwar.report( self.__logger ) + + query = lambda decl: decl.ignore == False and decl._already_exposed == False + + for cls in decls: + internal_decls = cls.classes( query, recursive=False, allow_empty=True) + dwar = duplicated_wrapper_aliases_reporter( internal_decls ) + dwar.report( self.__logger ) + + def inform_user( self ): + used_not_exported_decls = self.__find_out_used_but_not_exported() + groups = self.__group_by_unexposed( used_not_exported_decls ) + for group in groups.itervalues(): + self.__logger.warn( self.__create_dependencies_msg( group ) ) + self.__report_duplicated_aliases() + self.__report_duplicated_wrapper_aliases() Modified: pyplusplus_dev/unittests/fundamental_tester_base.py =================================================================== --- pyplusplus_dev/unittests/fundamental_tester_base.py 2009-05-10 18:25:05 UTC (rev 1710) +++ pyplusplus_dev/unittests/fundamental_tester_base.py 2009-05-10 20:04:09 UTC (rev 1711) @@ -1,158 +1,156 @@ -# Copyright 2004-2008 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import os -import sys -import unittest -import autoconfig -import pygccxml -from pygccxml import parser -from pyplusplus import utils -from pygccxml import declarations -from pyplusplus import module_builder - -LICENSE = """// Copyright 2004-2008 Roman Yakovenko. -// Distributed under the Boost Software License, Version 1.0. (See -// accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt)""" - -class fundamental_tester_base_t( unittest.TestCase ): - SUFFIX_TO_BE_EXPORTED = '_to_be_exported.hpp' - - def __init__(self, module_name, *args, **keywd ): - unittest.TestCase.__init__(self, *args) - self.__module_name = module_name - self.__to_be_exported_header \ - = os.path.join( autoconfig.data_directory - , self.__module_name + self.SUFFIX_TO_BE_EXPORTED ) - - self.__generated_source_file_name = os.path.join( autoconfig.build_dir - , self.__module_name + '.cpp' ) - self.__generated_scons_file_name = os.path.join( autoconfig.build_dir - , self.__module_name + '.scons' ) - - self.__indexing_suite_version = keywd.get( 'indexing_suite_version', 1 ) - - def failIfRaisesAny(self, callableObj, *args, **kwargs): - try: - callableObj(*args, **kwargs) - except Exception, error: - self.fail( 'exception has been raised during execution. exception: ' + str(error) ) - - def failIfNotRaisesAny(self, callableObj, *args, **kwargs): - was_exception = False - try: - callableObj(*args, **kwargs) - except: - was_exception = True - self.failUnless(was_exception, 'exception has not been raised during execution.') - - def __test_already_exposed( self, mb ): - exposed_db = utils.exposed_decls_db_t() - exposed_db.load( autoconfig.build_dir ) - irrelevant_decl_types = ( declarations.typedef_t - , declarations.namespace_t - , declarations.free_operator_t ) - specially_exposed_decls = mb.code_creator.specially_exposed_decls - for d in mb.decls(): - if not d.exportable: - continue - elif isinstance( d, declarations.free_operator_t ): - continue - elif d.ignore: - if d in specially_exposed_decls: - continue - if exposed_db.is_exposed( d ): - i = 0 - self.failUnless( not exposed_db.is_exposed( d ) - , '''Declaration "%s" is NOT exposed, but for some reason it is marked as such.''' - % str( d ) ) - #if d.ignore or not d.exportable or isinstance( d, irrelevant_decl_types ): - #continue - #if d.parent and not d.parent.name: - #continue #unnamed classes - else: - self.failUnless( exposed_db.is_exposed( d ) - , '''Declaration "%s" is exposed, but for some reason it isn't marked as such.''' - % str( d ) ) - - def customize(self, generator): - pass - - def get_source_files( self ): - sources = [ self.__generated_source_file_name ] - to_be_exported_cpp = os.path.splitext( self.__to_be_exported_header )[0] + '.cpp' - if os.path.exists( to_be_exported_cpp ): - sources.append( to_be_exported_cpp ) - return sources - - def generate_source_files( self, mb ): - mb.write_module( self.__generated_source_file_name ) - - def run_tests(self, module): - raise NotImplementedError() - - def _create_extension_source_file(self): - global LICENSE - - mb = module_builder.module_builder_t( [self.__to_be_exported_header] - , gccxml_path=autoconfig.gccxml.executable - , include_paths=[autoconfig.boost.include] - , undefine_symbols=['__MINGW32__'] - , indexing_suite_version=self.__indexing_suite_version - , compiler=autoconfig.cxx_parsers_cfg.gccxml.compiler) - for decl in mb.decls(): - decl.documentation = '"documentation"' - self.customize( mb ) - doc_extractor = lambda decl: decl.documentation - if not mb.has_code_creator(): - mb.build_code_creator( self.__module_name, doc_extractor=doc_extractor ) - mb.code_creator.std_directories.extend( autoconfig.scons_config.cpppath ) - mb.code_creator.user_defined_directories.append( autoconfig.data_directory ) - mb.code_creator.precompiled_header = "boost/python.hpp" - mb.code_creator.license = LICENSE - self.generate_source_files( mb ) - self.__test_already_exposed( mb ) - - def _create_sconstruct(self, sources ): - sources_str = [] - for source in sources: - sources_str.append( "r'%s'" % source ) - sources_str = ','.join( sources_str ) - sconstruct_script = autoconfig.scons_config.create_sconstruct()\ - % { 'target' : self.__module_name - , 'sources' : sources_str } - sconstruct_file = file( self.__generated_scons_file_name, 'w+b' ) - sconstruct_file.write( sconstruct_script ) - sconstruct_file.close() - - def _clean_build( self, sconstruct_file ): - cmd = autoconfig.scons.cmd_clean % sconstruct_file - output = os.popen( cmd ) - scons_reports = [] - while True: - data = output.readline() - scons_reports.append( data ) - if not data: - break - exit_status = output.close() - scons_msg = ''.join(scons_reports) - if exit_status: - raise RuntimeError( "unable to clean extension. error: %s" % scons_msg ) - - def test(self): - pypp = None - try: - self._create_extension_source_file() - sources = self.get_source_files() - self._create_sconstruct(sources) - autoconfig.scons_config.compile( autoconfig.scons.cmd_build + ' --file=%s' % self.__generated_scons_file_name ) - pypp = __import__( self.__module_name ) - self.run_tests(pypp) - finally: - if sys.modules.has_key( self.__module_name ): - del sys.modules[self.__module_name] - del pypp - #self._clean_build(self.__generated_scons_file_name) +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys +import unittest +import autoconfig +import pygccxml +from pygccxml import parser +from pyplusplus import utils +from pygccxml import declarations +from pyplusplus import module_builder + +LICENSE = """// Copyright 2004-2008 Roman Yakovenko. +// Distributed under the Boost Software License, Version 1.0. (See +// accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt)""" + +class fundamental_tester_base_t( unittest.TestCase ): + SUFFIX_TO_BE_EXPORTED = '_to_be_exported.hpp' + + def __init__(self, module_name, *args, **keywd ): + unittest.TestCase.__init__(self, *args) + self.__module_name = module_name + self.__to_be_exported_header \ + = os.path.join( autoconfig.data_directory + , self.__module_name + self.SUFFIX_TO_BE_EXPORTED ) + + self.__generated_source_file_name = os.path.join( autoconfig.build_dir + , self.__module_name + '.cpp' ) + self.__generated_scons_file_name = os.path.join( autoconfig.build_dir + , self.__module_name + '.scons' ) + + self.__indexing_suite_version = keywd.get( 'indexing_suite_version', 1 ) + + def failIfRaisesAny(self, callableObj, *args, **kwargs): + try: + callableObj(*args, **kwargs) + except Exception, error: + self.fail( 'exception has been raised during execution. exception: ' + str(error) ) + + def failIfNotRaisesAny(self, callableObj, *args, **kwargs): + was_exception = False + try: + callableObj(*args, **kwargs) + except: + was_exception = True + self.failUnless(was_exception, 'exception has not been raised during execution.') + + def __test_already_exposed( self, mb ): + exposed_db = utils.exposed_decls_db_t() + exposed_db.load( autoconfig.build_dir ) + irrelevant_decl_types = ( declarations.typedef_t + , declarations.namespace_t + , declarations.free_operator_t ) + specially_exposed_decls = mb.code_creator.specially_exposed_decls + for d in mb.decls(): + if not d.exportable: + continue + elif isinstance( d, declarations.free_operator_t ): + continue + elif d.ignore: + if d in specially_exposed_decls: + continue + if exposed_db.is_exposed( d ): + i = 0 + self.failUnless( not exposed_db.is_exposed( d ) + , '''Declaration "%s" is NOT exposed, but for some reason it is marked as such.''' + % str( d ) ) + elif d.parent \ + and isinstance( d.parent, declarations.class_t ) \ + and d.parent.indexing_suite: + continue + else: + self.failUnless( exposed_db.is_exposed( d ) + , '''Declaration "%s" is exposed, but for some reason it isn't marked as such.''' + % str( d ) ) + + def customize(self, generator): + pass + + def get_source_files( self ): + sources = [ self.__generated_source_file_name ] + to_be_exported_cpp = os.path.splitext( self.__to_be_exported_header )[0] + '.cpp' + if os.path.exists( to_be_exported_cpp ): + sources.append( to_be_exported_cpp ) + return sources + + def generate_source_files( self, mb ): + mb.write_module( self.__generated_source_file_name ) + + def run_tests(self, module): + raise NotImplementedError() + + def _create_extension_source_file(self): + global LICENSE + + mb = module_builder.module_builder_t( [self.__to_be_exported_header] + #, undefine_symbols=['__MINGW32__'] + , indexing_suite_version=self.__indexing_suite_version + , gccxml_config=autoconfig.cxx_parsers_cfg.gccxml) + for decl in mb.decls(): + decl.documentation = '"documentation"' + self.customize( mb ) + doc_extractor = lambda decl: decl.documentation + if not mb.has_code_creator(): + mb.build_code_creator( self.__module_name, doc_extractor=doc_extractor ) + mb.code_creator.std_directories.extend( autoconfig.scons_config.cpppath ) + mb.code_creator.user_defined_directories.append( autoconfig.data_directory ) + mb.code_creator.precompiled_header = "boost/python.hpp" + mb.code_creator.license = LICENSE + self.generate_source_files( mb ) + self.__test_already_exposed( mb ) + + def _create_sconstruct(self, sources ): + sources_str = [] + for source in sources: + sources_str.append( "r'%s'" % source ) + sources_str = ','.join( sources_str ) + sconstruct_script = autoconfig.scons_config.create_sconstruct()\ + % { 'target' : self.__module_name + , 'sources' : sources_str } + sconstruct_file = file( self.__generated_scons_file_name, 'w+b' ) + sconstruct_file.write( sconstruct_script ) + sconstruct_file.close() + + def _clean_build( self, sconstruct_file ): + cmd = autoconfig.scons.cmd_clean % sconstruct_file + output = os.popen( cmd ) + scons_reports = [] + while True: + data = output.readline() + scons_reports.append( data ) + if not data: + break + exit_status = output.close() + scons_msg = ''.join(scons_reports) + if exit_status: + raise RuntimeError( "unable to clean extension. error: %s" % scons_msg ) + + def test(self): + pypp = None + try: + self._create_extension_source_file() + sources = self.get_source_files() + self._create_sconstruct(sources) + autoconfig.scons_config.compile( autoconfig.scons.cmd_build + ' --file=%s' % self.__generated_scons_file_name ) + pypp = __import__( self.__module_name ) + self.run_tests(pypp) + finally: + if sys.modules.has_key( self.__module_name ): + del sys.modules[self.__module_name] + del pypp + #self._clean_build(self.__generated_scons_file_name) Modified: pyplusplus_dev/unittests/virtual_inheritance_tester.py =================================================================== --- pyplusplus_dev/unittests/virtual_inheritance_tester.py 2009-05-10 18:25:05 UTC (rev 1710) +++ pyplusplus_dev/unittests/virtual_inheritance_tester.py 2009-05-10 20:04:09 UTC (rev 1711) @@ -1,35 +1,38 @@ -# Copyright 2004-2008 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) - -import os -import sys -import unittest -import fundamental_tester_base - -class tester_t(fundamental_tester_base.fundamental_tester_base_t): - EXTENSION_NAME = 'virtual_inheritance' - - def __init__( self, *args ): - fundamental_tester_base.fundamental_tester_base_t.__init__( - self - , tester_t.EXTENSION_NAME - , *args ) - - def customize( self, mb ): - mb.classes().always_expose_using_scope = True - - def run_tests( self, module): - pass - -def create_suite(): - suite = unittest.TestSuite() - suite.addTest( unittest.makeSuite(tester_t)) - return suite - -def run_suite(): - unittest.TextTestRunner(verbosity=2).run( create_suite() ) - -if __name__ == "__main__": - run_suite() +# Copyright 2004-2008 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +import os +import sys +import unittest +import fundamental_tester_base + +EXPECTED_TO_FAIL = True +EXPECTED_TO_FAIL_INFO = "Boost.Python doesn't support virtual inheritance" + +class tester_t(fundamental_tester_base.fundamental_tester_base_t): + EXTENSION_NAME = 'virtual_inheritance' + + def __init__( self, *args ): + fundamental_tester_base.fundamental_tester_base_t.__init__( + self + , tester_t.EXTENSION_NAME + , *args ) + + def customize( self, mb ): + mb.classes().always_expose_using_scope = True + + def run_tests( self, module): + pass + +def create_suite(): + suite = unittest.TestSuite() + suite.addTest( unittest.makeSuite(tester_t)) + return suite + +def run_suite(): + unittest.TextTestRunner(verbosity=2).run( create_suite() ) + +if __name__ == "__main__": + run_suite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |