c++code-coveragebazel

How to merge coverage reports (.dat) from multiple tests in Bazel


If I have run the unique C++ test with different data fed in. How can I merge .dat reports for each run of test?

I can generate C++ code coverage reports (.dat file) in Bazel through:

bazel coverage //tests --instrumentation_filter="^..."

This generates an overall coverage report for the filtered path. And I can transform the .dat report into .html files by genhtml.

However, I have to feed my test with multiple sets of data though the test itself does not need to be modified. Worse still, I cannot separate the test into multiple tests loading different datasets due to some reasons.


Solution

  • Well, I have got a solution with lcov:

    lcov -a ${path_of_dat_file_1} -a ${path_of_dat_file_2} ... -o merged_report.dat
    

    The lcov can merge the .dat reports into one .dat report. And then we can get the .html report with:

    genhtml merged_report.dat -o ${output_folder_path}