如何使用Bazel获取python的代码覆盖率

时间:2019-06-25 15:58:26

标签: bazel

我想使用Bazel为我的所有python测试生成代码覆盖率报告。当前,我正在使用Bazel版本0.19.1,但是不久我将升级到0.22.0。我发现了2017年以来的一个未解决的错误,该错误已解决了一段时间,但此页面上的交流突然中断(https://github.com/bazelbuild/rules_python/issues/43)。有人知道bazel coverage在哪里支持py_tests和py_binaries的代码覆盖率吗?

当前,当我运行命令bazel coverage //path/to/python/tests/...

(verb_py3) joshsullivan@VERB790-Linux:~/verb/test_folder1$ bazel coverage test_sub1/...
INFO: Using default value for --instrumentation_filter: "//test_folder1/test_sub1[/:]".
INFO: Override the above default with --instrumentation_filter
INFO: Build options have changed, discarding analysis cache.
INFO: Analysed 8 targets (2 packages loaded, 7612 targets configured).
INFO: Found 8 test targets...
FAIL: //test_folder1/test_sub1:tests_marked_test (see /home/joshsullivan/.cache/bazel/_bazel_joshsullivan/05ff476f42160380dc4701b6f3f01f26/execroot/verb/bazel-out/k8-fastbuild/testlogs/test_folder1/test_sub1/tests_marked_test/test.log)
ERROR: /home/joshsullivan/verb/test_folder1/test_sub1/BUILD:21:1: output 'test_folder1/test_sub1/tests_marked_test/coverage.dat' was not created
ERROR: /home/joshsullivan/verb/test_folder1/test_sub1/BUILD:21:1: not all outputs were created or valid
INFO: Elapsed time: 0.933s, Critical Path: 0.25s, Remote (0.00% of the time): [queue: 0.00%, setup: 0.00%, process: 0.00%]
INFO: 3 processes: 3 linux-sandbox.
FAILED: Build did NOT complete successfully
//test_folder1/test_sub1:buildifier_test__BUILD                       NO STATUS
//test_folder1/test_sub1:clang_format_test                            NO STATUS
//test_folder1/test_sub1:cpplint_test                                 NO STATUS
//test_folder1/test_sub1/tests:buildifier_test__BUILD                 NO STATUS
//test_folder1/test_sub1/tests:clang_format_test                      NO STATUS
//test_folder1/test_sub1/tests:cpplint_test                           NO STATUS
//test_folder1/test_sub1/tests:tests_marked_test                      NO STATUS
//test_folder1/test_sub1:tests_marked_test                               FAILED in 0.2s
  /home/joshsullivan/.cache/bazel/_bazel_joshsullivan/05ff476f42160380dc4701b6f3f01f26/execroot/verb/bazel-out/k8-fastbuild/testlogs/test_folder1/test_sub1/tests_marked_test/test.log

FAILED: Build did NOT complete successfully

这为我提供了空白的coverage.dat文件

我正在寻找一种使用bazel coverage的方法,以便通过我的测试,并使用已运行的所有测试的合并coverage结果生成共享的coverage.dat文件。这样,我可以获取coverage.dat文件,并使用该文件生成html报告。任何帮助都将不胜感激!

0 个答案:

没有答案