简体   繁体   中英

How to merge coverage from multiple .dat files in Bazel

I am able to generate coverage.dat files with bazel command:

bazel coverage //tests/... --instrumented_filter=/src[/:]

This generates report for one of the classes, because coverage.dat files are generated separately for each instrumented file in different directories. How do I get a merged coverage.dat?

The coverage.dat report should contain coverage information about all the classes affected by the --instrumentation_filter . This file should be located under bazel-testlogs/path/to/your/package/TestTarget .

You shouldn't have to write anything additional. Bazel does generate multiple temporary .dat files, but it merges all of them in the final coverage.dat file, whose location is printed by bazel when it finishes to run. That file is the one with the location I described above. Make sure to check that file and check if you're using --instrumentation_filter (*) correctly.

(*) From the command line manual :

When coverage is enabled, only rules with names included by the specified regex- based filter will be instrumented. Rules prefixed with '-' are excluded instead. Note that only non-test rules are instrumented unless -- instrument_test_targets is enabled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM