Example #1
0
def textSummary(args, filesAndTests, gCovResults, prefix=""):

    summary = GCov.computeSummary(filesAndTests, gCovResults)

    if not args.includeTestSources:
        summary = GCovSummary.removeTestSourceFiles(summary)

    if len(summary) == 0:
        return

    if args.explain:
        pp = pprint.PrettyPrinter(indent=2, width=150)
        pp.pprint(summary)

    maximumFileLength = max(map(lambda entry: len(entry), summary))

    format = "%s%-" + str(maximumFileLength) + "s %6s"
    print format % (prefix, "File Path", "Score")

    format = "%s%-" + str(maximumFileLength) + "s %6.2f"
    for testedFile in sorted(summary.keys()):
        string = format % (prefix, testedFile, summary[testedFile]["coverage"])
        if summary[testedFile]["direct"] == "indirect":
            ANSITerm.printColorized("magenta", string)
        else:
            LongBow.scorePrinter(eval(args.distribution),
                                 summary[testedFile]["coverage"], string)

    return
Example #2
0
def textSummary(args, filesAndTests, gCovResults, prefix=""):

    summary = GCov.computeSummary(filesAndTests, gCovResults)

    if not args.includeTestSources:
        summary = GCovSummary.removeTestSourceFiles(summary)

    if len(summary) == 0:
        return

    if args.explain:
        pp = pprint.PrettyPrinter(indent=2, width=150)
        pp.pprint(summary)

    maximumFileLength = max(map(lambda entry: len(entry), summary))

    format = "%s%-" + str(maximumFileLength) + "s %6s"
    print format % (prefix, "File Path", "Score")

    format = "%s%-" + str(maximumFileLength) + "s %6.2f"
    for testedFile in sorted(summary.keys()):
        string = format % (prefix, testedFile, summary[testedFile]["coverage"])
        if summary[testedFile]["direct"] == "indirect":
            ANSITerm.printColorized("magenta", string)
        else:
            LongBow.scorePrinter(eval(args.distribution), summary[testedFile]["coverage"], string)

    return
Example #3
0
def textVisualDisplayGcovLine(line):
    token = line.split(":", 2)
    if len(token) == 3:
        if token[0] == "#####":
            print ANSITerm.colorize("red", token[1] + " " + token[2])
        elif token[0] == "$$$$$":
            print ANSITerm.colorize("yellow", token[1] + " " + token[2])
        else:
            print ANSITerm.colorize("green", token[1] + " " + token[2])

    return
Example #4
0
def textVisualDisplayGcovLine(line):
    token = line.split(":", 2)
    if len(token) == 3:
        if token[0] == "#####":
            print ANSITerm.colorize("red", token[1] + " " + token[2])
        elif token[0] == "$$$$$":
            print ANSITerm.colorize("yellow", token[1] + " " + token[2])
        else:
            print ANSITerm.colorize("green", token[1] + " " + token[2])

    return
Example #5
0
    def explain(self):
        self.exemplarData = getExemplar(self.fileName, self.exemplarCommand,
                                        self.exemplarConfig)
        differ = diff(self.fileData, self.exemplarData)

        ansiTerm = ANSITerm.ANSITerm()

        for l in differ:
            if l[0] == '-':
                ansiTerm.printColorized("red", l)
            elif l[0] == '+':
                ansiTerm.printColorized("green", l)
            elif l[0] == '?':
                ansiTerm.printColorized("yellow", l[0:len(l) - 1])
            else:
                print l
                pass
        return