Skip to content
Converts lcov output to Cobertura-compatible XML for CI
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc Project overhaul: refactoring, testing, and distribution Sep 5, 2012
lcov_cobertura Make a few minor changes so lcov_cobertura.py can be run as a console… Mar 3, 2016
test
.gitignore Ignoring docs Sep 22, 2012
.travis.yml Ignoring stupid whitespace inconsistencies between python 2.6 and 2.7 Jan 18, 2013
CHANGELOG.md Adding CHANGELOG Oct 2, 2012
CONTRIBUTING.md
LICENSE Update LICENSE to adhere to Apache licensing guidelines Dec 6, 2016
MANIFEST
MANIFEST.in Project overhaul: refactoring, testing, and distribution Sep 5, 2012
Makefile Adding support for function coverage Oct 2, 2012
README.md Update README.md Mar 3, 2016
RELEASE Adding release instruction so I don't eff it up Nov 15, 2012
setup.py

README.md

lcov to cobertura XML converter Build Status

This project does as the name implies: it coverts code coverage report files in lcov format to Cobertura's XML report format so that CI servers like Jenkins can aggregate results and determine build stability etc.

Coverage metrics supported:

  • Package/folder overall line and branch coverage
  • Class/file overall line and branch coverage
  • Functions hit
  • Line and Branch hits

Quick usage

Grab it raw and run it with python:

python lcov_cobertura.py lcov-file.dat
  • -b/--base-dir - (Optional) Directory where source files are located. Defaults to the current directory
  • -e/--excludes - (Optional) Comma-separated list of regexes of packages to exclude
  • -o/--output - (Optional) Path to store cobertura xml file. Defaults to ./coverage.xml
  • -d/--demangle - (Optional) Demangle C++ function names. Requires c++filt
python lcov_cobertura.py lcov-file.dat --base-dir src/dir --excludes test.lib --output build/coverage.xml --demangle

With pip:

pip install lcov_cobertura

Command-line usage

lcov_cobertura lcov-file.dat
  • -b/--base-dir - (Optional) Directory where source files are located. Defaults to the current directory
  • -e/--excludes - (Optional) Comma-separated list of regexes of packages to exclude
  • -o/--output - (Optional) Path to store cobertura xml file. Defaults to ./coverage.xml
  • -d/--demangle - (Optional) Demangle C++ function names. Requires c++filt
lcov_cobertura lcov-file.dat --base-dir src/dir --excludes test.lib --output build/coverage.xml --demangle

Usage as a Python module

Use it anywhere in your python:

from lcov_cobertura import LcovCobertura

LCOV_INPUT = 'SF:foo/file.ext\nDA:1,1\nDA:2,0\nend_of_record\n'
converter = LcovCobertura(LCOV_INPUT)
cobertura_xml = converter.convert()
print(cobertura_xml)

Environment Support

Python 2.6+ is supported (including Python 3). You can also use the experimental Jython 2.5 friendly version in the jython branch.

Contributions

This project is made possible due to the efforts of these fine people:

License

This project is provided under the Apache License, Version 2.0.

I provide this software free of charge. If you find it helpful, please endorse me for Python on coderwall: endorse

You can’t perform that action at this time.