See UPDATE below.
I think the intended way to do this is not to combine the .gcda
files directly but to create independent coverage data files using
lcov -o unittests.coverage -c -d unittests
lcov -o integrationtests.coverage -c -d integrationtests
Each coverage data then represents one "run". You can of course create separate graphs or html views. But you can also combine the data using --add-tracefile
, -a
for short
lcov -o total.coverage -a unittests.coverage -a integrationtests.coverage
From the total.coverage
you can generate the total report, using genhtml
for example.
UPDATE: I found that it is actually possible to merge .gcda
files directly using gcov-tool
, which unfortunately are not easily available on the Mac, so this update doesn't answer the original question.
But with gcov-tool
you can even incrementally merge many set together into one:
gcov-tool merge dir1 dir -o dir
gcov-tool merge dir2 dir -o dir
gcov-tool merge dir3 dir -o dir
Although that is not documented and might be risky to rely on.
This is really fast and avoids the round-about way over lcov, which is much slower when merging many sets. Merging some 80 sets of 70 files takes under .5 second on my machine. And you can still do an lcov
on the aggregated set, which also is very much faster, should you need it. I use Emacs cov-mode
which uses the .gcov
files directly.
See this answer for details.