Merging coverage reports

Sep 2, 2015 at 10:01 AM
Hi,

I was first under the assumption that it was possible to merge several coverage reports into one, but now I noticed that the example in the documentation is using different .exe files for each run.

My usecase is that I want to run the same program multiple times and then merge all the reports. I did not manage to get that to work, I see no errors but it seems that the reported coverage is only for one of the runs. I did it similar to this:
OpenCppCoverage --sources=MySources --export_type=binary:test_01.cov -- Test.exe
OpenCppCoverage --sources=MySources --export_type=binary:test_02.cov -- Test.exe
OpenCppCoverage --sources=MySources --input_coverage=test_01.cov --input_coverage=test_02.cov  -- Test.exe
Is that not supported or am I using it incorrectly ?
Coordinator
Sep 2, 2015 at 10:15 PM
Hi

I have just tested the following code (Output is ConsoleApplication1.exe):
int _tmain(int argc, TCHAR *argv[])
{
    std::srand(std::time(0));
    if (std::rand() % 2 == 0)
        std::cout << "Odd" << std::endl;
    else
        std::cout << "Even" << std::endl;

    return 0;
}
And run the commands with OpenCppCoverage 0.9.2.1:
OpenCppCoverage --sources=ConsoleApplication1 --export_type=binary:test_01.cov -- ConsoleApplication1.exe
OpenCppCoverage --sources=ConsoleApplication1 --export_type=binary:test_02.cov -- ConsoleApplication1.exe
OpenCppCoverage --sources=ConsoleApplication1 --input_coverage=test_01.cov --input_coverage=test_02.cov  --export_type=cobertura -- ConsoleApplication1.exe
I have 100% coverage after a few tries (--export_type=cobertura is required in my case because of a problem in Windows 10 fixed in next release 0.9.3).

You run Test.exe without any argument. Is it normal? If you do not have some kinds of randomness or external notification like client/server, your program will have the same behaviour each time and so will have the same coverage.

I suggest that you add some logs and check that your program behave differently for each run.

Tell me if that fix your issue or not,

OpenCppCoverage
Sep 3, 2015 at 10:51 AM
Hi, and thanks for looking into this.

I do run without any args, but this is an application that is interacted with using an external process so each run is different.

Nevertheless I managed to find the problem now, I had some of the runs passing a path of the form C:\A\B\.. instead of C:\A to --sources. So in theory both should point to the same directory but for some reason using the path containing ".." does not work.

So from my side I have solved this issue now. But could OpenCppCoverage be fixed to handle such paths too (or at least give an error message if the path does not exist or is not supported) ?
Coordinator
Nov 16, 2015 at 9:23 PM
Hello,

Sorry for the long delay. I wanted to wait for a fix to answer you. As there is a new release soon, I have just tried to fix your point.
Unfortunately, I cannot make a fix without some magic. In --sources arg, arg is not necessary a path. Please see https://opencppcoverage.codeplex.com/wikipage?title=Command-Line%20Reference. So most of the time, arg is a part of the path.
It seems the argument of --sources is not clear. I will improve the error message to be more explicit about the meaning of the argument of --sources.

Please tell me if I misunderstood your point,

OpenCppCoverage
Marked as answer by OpenCppCoverage on 4/3/2016 at 1:52 AM