Example #1
0
    def collect(self, test):
        # run lcov to get the test coverage file
        outfile = os.path.join(test.env()['RESULTS_DIR'],
                               CCoverageCollector.FILENAME)

        # create the coverage
        try:
            lcov.collect(outfile,
                         self.srcdirs,
                         CCoverageCollector.BASELINE,
                         extract=self.extract,
                         remove=self.remove,
                         branch_coverage=self.branch_coverage)
        except lcov.LcovError as e:
            logger.warn("Lcov collection failed: `%s`" % e)

            # the baseline is now the resulting coverage
            shutil.copyfile(CCoverageCollector.BASELINE, outfile)

        # if lcov ran correctly
        # read the output file
        with open(outfile) as fh:
            out = fh.read()

        try:
            return lcov.parse(out)
        except TypeError as e:
            logger.warn("Unable to parse lcov data: `%s`" % e)
            return {}
Example #2
0
	def collect( self, test ):
		# run lcov to get the test coverage file
		outfile = os.path.join( test.env()[ 'RESULTS_DIR' ], CCoverageCollector.FILENAME )

		# create the coverage
		try:
			lcov.collect( outfile, self.srcdirs, CCoverageCollector.BASELINE,
				extract=self.extract,
				remove=self.remove,
				branch_coverage=self.branch_coverage
			)
		except lcov.LcovError as e:
			logger.warn(
				"Lcov collection failed: `%s`" % e
			)

			# the baseline is now the resulting coverage
			shutil.copyfile( CCoverageCollector.BASELINE, outfile )

		# if lcov ran correctly
		# read the output file
		with open( outfile ) as fh:
			out = fh.read()

		try:
			return lcov.parse( out )
		except TypeError as e:
			logger.warn( "Unable to parse lcov data: `%s`" % e )
			return {}
Example #3
0
    def get_result(self):
        lcov.combine(self.collectpath, paths=self.paths)

        with open(self.collectpath) as fh:
            # parse the accumulated data
            results = lcov.parse(fh.read())

        return results
Example #4
0
	def get_result( self ):
		lcov.combine( self.collectpath, paths=self.paths )

		with open( self.collectpath ) as fh:
			# parse the accumulated data
			results = lcov.parse( fh.read() )

		return results