Lcoveralls is a simple (Ruby) script for reporting code coverage results from
LCOV to Coveralls.
Instead of invoking gcov
directly, as some alternative projects do (quite successfully),
Lcoveralls depends on the tracefiles that LCOV generates from g++ / gcov's output.
The benefit of using LCOV's tracefiles (aka *.info files) is two-fold:
- LCOV's inclusion / exclusion logic is well proven, and time tested - no need to reinvent that wheel; and
- If you are already using LCOV to generate HTML output (as I usually do), then you only need to define inclusions / exclusions once, instead of having to define that information twice (and in two very different formats).
Of course, the disadvantage to depending on LCOV, is the additional dependency - not an issue for me, but I guess it could be for someone.
gem install lcoveralls
- Build your project with gcov support.
- Execute your test(s).
- Execute
lcov
to generate tracefiles (aka *.info files). - Execute
lcoveralls
to submit the coverage report(s) to Coveralls.
For example:
g++ -fprofile-arcs -ftest-coverage -O0 -o test <source files>
./test
lcov --capture ... && lcov --remove ...
lcoveralls [--token <coveralls repo token>]
The token is not necessary when using Travis CI. Run lcoveralls --help
for
more options.
To use Lcoveralls within Travis CI, simply install the gem, and then once all of
your tests have passed (including any necessary lcov
invocations), invoke
lcoveralls.
For example:
install:
- sudo apt-get install lcov rubygems
- gem install lcoveralls
...
after_success:
- lcoveralls
Note, if you are using Travis Pro, you should let Lcoveralls know via the
--service
option, for example:
after_success:
- lcoverals --service travis-pro
Some real-word Travis CI examples:
Project | .travis.yml |
---|---|
libqtaws | .travis.yml |
pcp-pmda-cpp | .travis.yml |
Apache License 2.0