I'm using code coverage on different test suites and those suites are launched under different directories.
Say my suite1 is launched in directory /path1/mysoft/src
and my suite2 is launched in directory /path2/mysoft/src/
I launch lcov in /path1/mysoft
(respectively with path2
) using lcov -d . -c -o suite1.info
(resp. with suite2
).
Then I want to cumulate the coverage from both test suites. I copy the suite1.info
and suite2.info
files in another directory /path3/mysoft
which also contains the source code from my program.
I can cumulate both with lcov -a suite1.info -a suite2.info -o tests.info
however the coverage for a given file src/example.c
won't be cumulated as lcov
will condider that /path1/mysoft/src/example.c
and /path2/mysoft/src/example.c
are two different files. Therefore cumulating won't work.
How can I cumulate code coverage for the same source code coming from different base directories?
Some unsatistfying solutions
- Removing the base directories by launching
lcov -d . -c --rc geninfo_adjust_src_path=/path1 -o suite1.info
. In this case the coverage will be cumulated correctly bylcov
, howevergenhtml
will fail because it won't find the source code at the correct place. At this time I don't know whatpath3
will be, so I can't replacepath1
bypath3
. - Renaming the base directories when cumulating
lcov
outputs by using the samegeninfo_adjust_src_path
option. I've been unable to do so: launchinglcov -a suite1.info -a suite2.info --rc geninfo_adjust_src_path='path1 => path3' --rc geninfo_adjust_src_path='path1 => path2' -o tests.info
didn't change anything. - Launching everying in the same base directory (see below)
Some context
Why am I launching my test suites in different base directories? Well actually the continuous integration is doing that. So path1
is something like /home/gitlab/builds/b8e873c2/0/
. The test suites are each launched in a different job and cumulating the coverage is also done in another job. Each job is launched in a different base directory and the .info
files are retrieved using artifacts.
Thanks for any help!