#NEWLINE# def do_coverage( project , logger , reactor , execution_prefix , execution_name , target_task , shortest_plan ) : #NEWLINE# #INDENT# "\n    This function MUST ALWAYS execute in a fork.\n    The sys.modules will be manipulated extensively to stage the tests properly, which may affect execute down the line.\n    It's best to simple let this method exit and the fork die rather than to try to recover.\n    " #NEWLINE# source_tree_path = project . get_property ( 'dir_source_main_python' ) #NEWLINE# reset_modules = project . get_property ( ( '%s_reset_modules' % execution_prefix ) ) #NEWLINE# module_names = _discover_modules_to_cover ( project ) #NEWLINE# for module_name in module_names : #NEWLINE# #INDENT# logger . debug ( "Module '%s' coverage to be verified" , module_name ) #NEWLINE# #UNINDENT# if ( reset_modules and ( not is_windows ( ) ) ) : #NEWLINE# #INDENT# _delete_non_essential_modules ( ) #NEWLINE# __import__ ( 'pybuilder.plugins.python' ) #NEWLINE# #UNINDENT# from coverage import coverage as coverage_factory #NEWLINE# coverage = coverage_factory ( cover_pylib = False , branch = True , source = [ source_tree_path ] ) #NEWLINE# try : #NEWLINE# #INDENT# _start_coverage ( project , coverage ) #NEWLINE# if shortest_plan : #NEWLINE# #INDENT# reactor . execute_task_shortest_plan ( target_task ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# reactor . execute_task ( target_task ) #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# _stop_coverage ( project , coverage ) #NEWLINE# #UNINDENT# module_exceptions = project . get_property ( ( '%s_exceptions' % execution_prefix ) ) #NEWLINE# modules = _list_all_covered_modules ( logger , module_names , module_exceptions ) #NEWLINE# failure = _build_coverage_report ( project , logger , execution_name , execution_prefix , coverage , logger ) #NEWLINE# if failure : #NEWLINE# #INDENT# raise failure