def csvAverage(args, filesAndTests, gcovResults): summary = GCov.computeSummary(filesAndTests, gcovResults) if not args.includeTestSources: summary = GCovSummary.removeTestSourceFiles(summary) score = GCovSummary.averageCoverage(summary) LongBow.scorePrinter(eval(args.distribution), score, "%.2f" % (score)) return
def gradeAndPrint(targets, testDirs=[], problemsOnly=False, prefix=""): filesAndTests = getFilesAndTests(targets, testDirs) newGCovResults = map( lambda fileAndTestFile: GCov.getCoverage(fileAndTestFile[1]), filesAndTests) summarys = GCov.computeSummary(filesAndTests, newGCovResults) if len(summarys) < 1: print "%sNo GCov Results - Please be sure to run 'make check' first" % prefix return False summarys = GCovSummary.removeTestSourceFiles(summarys) paths = summarys.keys() if problemsOnly: paths = filter(lambda key: summarys[key]["coverage"] < 100, paths) distribution = [99, 90] maximumFileLength = max( map(lambda entry: len(os.path.relpath(entry)), paths)) format = "%s%-" + str(maximumFileLength) + "s %6s" print format % (prefix, "File Path", "Score") format = "%s%-" + str(maximumFileLength) + "s %6.2f" for path in sorted(paths): string = format % (prefix, os.path.relpath(path), summarys[path]["coverage"]) LongBow.scorePrinter(distribution, summarys[path]["coverage"], string) return True
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
def csvSummary(args, filesAndTests, gCovResults): summary = GCov.computeSummary(filesAndTests, gCovResults) if not args.includeTestSources: summary = GCovSummary.removeTestSourceFiles(summary) if len(summary) > 0: for testedFile in sorted(summary.keys()): outputString = "%s,%.2f" % (testedFile, summary[testedFile]["coverage"]) LongBow.scorePrinter(eval(args.distribution), summary[testedFile]["coverage"], outputString) return
def gradeAndPrint(targets, testDirs=[], problemsOnly=False, prefix=""): filesAndTests = getFilesAndTests(targets, testDirs) newGCovResults = map(lambda fileAndTestFile: GCov.getCoverage(fileAndTestFile[1]), filesAndTests) summarys = GCov.computeSummary(filesAndTests, newGCovResults) if len(summarys) < 1: print "%sNo GCov Results - Please be sure to run 'make check' first" % prefix return False summarys = GCovSummary.removeTestSourceFiles(summarys) paths = summarys.keys() if problemsOnly: paths = filter(lambda key: summarys[key]["coverage"] < 100, paths) distribution=[99,90] maximumFileLength = max(map(lambda entry: len(os.path.relpath(entry)), paths)) format = "%s%-" + str(maximumFileLength) + "s %6s" print format % (prefix, "File Path", "Score") format = "%s%-" + str(maximumFileLength) + "s %6.2f" for path in sorted(paths): string = format % (prefix, os.path.relpath(path), summarys[path]["coverage"]) LongBow.scorePrinter(distribution, summarys[path]["coverage"], string) return True