简体   繁体   English

如何从Bazel中的多个.dat文件合并coverage

[英]How to merge coverage from multiple .dat files in Bazel

I am able to generate coverage.dat files with bazel command: 我可以使用bazel命令生成coverage.dat文件:

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. 这将为这些类之一生成报告,因为coverage.dat文件是针对不同目录中的每个检测文件单独生成的。 How do I get a merged coverage.dat? 如何获得合并的coverage.dat?

The coverage.dat report should contain coverage information about all the classes affected by the --instrumentation_filter . coverage.dat报告应包含有关--instrumentation_filter影响的所有类的覆盖率信息。 This file should be located under bazel-testlogs/path/to/your/package/TestTarget . 该文件应位于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. Bazel确实会生成多个临时.dat文件,但会将它们全部合并到最终的coverage.dat文件中,该文件的位置在运行完成时由bazel打印。 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. 确保检查该文件,并检查是否正确使用了--instrumentation_filter (*)。

(*) From the command line manual : (*) 从命令行手册

When coverage is enabled, only rules with names included by the specified regex- based filter will be instrumented. 启用coverage后,将仅使用名称包含在基于正则表达式的指定过滤器中的规则。 Rules prefixed with '-' are excluded instead. 以“-”为前缀的规则将被排除。 Note that only non-test rules are instrumented unless -- instrument_test_targets is enabled. 请注意,除非启用了instrument_test_targets,否则仅会检测非测试规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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