def commandLineMain(args, fileNames, testDir=""): testDirs = [] if testDir: testDirs.append(testDir) fileNames = map(lambda fileName: os.path.abspath(fileName), fileNames) filesAndTests = map( lambda fileName: [fileName, findTestExecutable(fileName, testDirs)], fileNames) filesWithNoTest = filter(lambda fileAndTest: fileAndTest[1] == None, filesAndTests) if len(filesWithNoTest) != 0: outputFormat = "%s has no corresponding test executable or coverage data.\n" map( lambda filesAndTests: sys.stderr.write(outputFormat % (filesAndTests[0])), filesWithNoTest) gCovResults = map( lambda fileAndTestFile: GCov.getCoverage(fileAndTestFile[1]), filesAndTests) if args.summary is True: displaySummary(args, filesAndTests, gCovResults) elif args.average is True: displayAverage(args, filesAndTests, gCovResults) elif args.visual is True: textVisual(args, filesAndTests, gCovResults) elif args.explain is True: explain(args, filesAndTests, gCovResults) return True
def commandLineMain(args, fileNames, testDir=""): testDirs = [] if testDir: testDirs.append(testDir) fileNames = map(lambda fileName: os.path.abspath(fileName), fileNames) filesAndTests = map(lambda fileName: [fileName, findTestExecutable(fileName, testDirs)], fileNames) filesWithNoTest = filter(lambda fileAndTest: fileAndTest[1] == None, filesAndTests) if len(filesWithNoTest) != 0: outputFormat = "%s has no corresponding test executable or coverage data.\n" map(lambda filesAndTests: sys.stderr.write(outputFormat % (filesAndTests[0])), filesWithNoTest) gCovResults = map(lambda fileAndTestFile: GCov.getCoverage(fileAndTestFile[1]), filesAndTests) if args.summary is True: displaySummary(args, filesAndTests, gCovResults) elif args.average is True: displayAverage(args, filesAndTests, gCovResults) elif args.visual is True: textVisual(args, filesAndTests, gCovResults) elif args.explain is True: explain(args, filesAndTests, gCovResults) return True
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 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