Changeset 2766


Ignore:
Timestamp:
04/12/12 10:38:21 (2 years ago)
Author:
jdsiiro
Message:

Process gcno files in addition to gcda files, but only if there is
no corresponding gcda file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gcovr/trunk/scripts/gcovr

    r2765 r2766  
    2525# For more information, see the FAST README.txt file. 
    2626# 
    27 # $Revision 2765 $ 
    28 # $Date 2012-04-12 09:41:11 -0700 (Thu, 12 Apr 2012) $ 
     27# $Revision 2766 $ 
     28# $Date 2012-04-12 10:38:21 -0700 (Thu, 12 Apr 2012) $ 
    2929# _________________________________________________________________________ 
    3030# 
     
    4444 
    4545__version__ = "2.4-prerelease" 
    46 src_revision = "$Revision 2765 $" 
     46src_revision = "$Revision 2766 $" 
    4747gcov_cmd = "gcov" 
    4848 
     
    308308    for root, dirs, files in link_walker(path): 
    309309        for name in files: 
    310            if pattern.match(name): 
     310            if pattern.match(name): 
    311311                name = os.path.join(root,name) 
    312312                if os.path.islink(name): 
     
    320320# Get the list of datafiles in the directories specified by the user 
    321321# 
    322 def get_datafiles(flist, options, ext="gcda"): 
     322def get_datafiles(flist, options): 
    323323    allfiles=[] 
    324324    for dir in flist: 
    325325        if options.verbose: 
    326             sys.stdout.write( "Scanning directory %s for %s files...\n" 
    327                               % (dir, ext) ) 
    328         files = search_file(".*\."+ext, dir) 
     326            sys.stdout.write( "Scanning directory %s for gcda/gcno files...\n" 
     327                              % (dir, ) ) 
     328        files = search_file(".*\.gc(da|no)$", dir) 
     329        # gcno files will *only* produce uncovered results; however, 
     330        # that is useful information for the case where a compilation 
     331        # unit is never actually exercised by the test code.  So, we 
     332        # will process gcno files, but ONLY if there is no corresponding 
     333        # gcda file. 
     334        gcda_files = [file for file in files if file.endswith('gcda')] 
     335        tmp = set(gcda_files) 
     336        gcno_files = [ file for file in files if 
     337                       file.endswith('gcno') and file[:-2]+'da' not in tmp ] 
    329338        if options.verbose: 
    330             sys.stdout.write("Found %d files \n" % len(files)) 
    331         allfiles += files 
     339            sys.stdout.write( 
     340                "Found %d files (and will process %d)\n" % 
     341                ( len(files), len(gcda_files) + len(gcno_files) ) ) 
     342        allfiles.extend(gcda_files) 
     343        allfiles.extend(gcno_files) 
    332344    return allfiles 
    333345 
     
    586598    os.chdir(starting_dir) 
    587599    if options.delete: 
    588         os.remove(abs_filename) 
     600        if not abs_filename.endswith('gcno'): 
     601            os.remove(abs_filename) 
    589602         
    590603    if not Done: 
Note: See TracChangeset for help on using the changeset viewer.