Skip to content

Report Gcov / LCOV (ie C, C++, Go, etc) code coverage to coveralls.io

License

Notifications You must be signed in to change notification settings

pcolby/lcoveralls

Repository files navigation

Lcoveralls

Build Status Gem Version Github Release Apache License

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.

Lcoveralls Data Flow

The benefit of using LCOV's tracefiles (aka *.info files) is two-fold:

  1. LCOV's inclusion / exclusion logic is well proven, and time tested - no need to reinvent that wheel; and
  2. 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.

Installation

gem install lcoveralls

Usage

  1. Build your project with gcov support.
  2. Execute your test(s).
  3. Execute lcov to generate tracefiles (aka *.info files).
  4. 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.

Travis CI

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

License

Apache License 2.0