示例#1
0
def main():
    from optparse import OptionParser
    op = OptionParser("usage: %prog [options] files")
    opts,args = op.parse_args()

    group = GCovGroup()
    for f in args:
        res = GCovParser.parseGCDA(f)
        group.addGCDA(res)

    print '%d total files'%(len(group.entryMap),)
示例#2
0
def main():
    from optparse import OptionParser
    op = OptionParser("usage: %prog [options] files")
    opts, args = op.parse_args()

    group = GCovGroup()
    for f in args:
        res = GCovParser.parseGCDA(f)
        group.addGCDA(res)

    print '%d total files' % (len(group.entryMap), )
示例#3
0
文件: scan.py 项目: tash/zcov
def action_scan(name, args):
    """create a coverage data file from gcov data"""

    from optparse import OptionParser
    global opts
    op = OptionParser("usage: %%prog %s [options] output {directories}" % (name,))
    op.add_option("", "--look-up-dirs",
                  action="store", dest="lookUpDirs", default=0, type=int,
                  metavar="N", help="when finding base paths, look up N directories")
    opts,args = op.parse_args(args)

    if not args:
        op.error('invalid number of arguments')
    output,dirs = args[0],args[1:]

    if not dirs:
        dirs = ['.']
        
    # Scan inputs for source files and for .gcdas
    sources = set()
    sourcedirs = set()
    gcdas = set()
    sourceFileMap = {}
    for dir in dirs:
        if not os.path.isdir(dir):
            op.error('Not a directory: "%s"'%(dir,))
        for path,dirnames,filenames in os.walk(os.path.abspath(dir)):
            sourcedirs.add(os.path.join(dir,path))
            if '.svn' in dirnames:
                dirnames.remove('.svn')
            for file in filenames:
                if file.endswith('.gcda'):
                    gcdas.add(os.path.join(path,file))

    print 'Found %d .gcdas (%d source dirs)'%(len(gcdas,), len(sourcedirs))
#    for f in gcdas:
#        gcdaFiles = GCovParser.getGCDAFiles(f)
#        print f,list(gcdaFiles)

    group = GCovGroup.GCovGroup()
    for gf in gcdas:
        # Determine the right directory to run gcov from so it can
        # find the all files.
        basepath = findGCDABasePath(gf, sourcedirs)
        if basepath is None:
            print >>sys.stderr, 'WARNING: Unable to find a base for "%s", skipping'%(gf,)
            continue
        res = GCovParser.parseGCDA(gf,basepath)
        group.addGCDA(res)

    group.tofile(output)