2

I would like to generate a code coverage report for all of my python tests using Bazel. Currently I am using Bazel version 0.19.1, but I will be upgrading to 0.22.0 shortly. I found this open bug from 2017, that was worked on for a while, but communication on this page just suddenly dropped (https://github.com/bazelbuild/rules_python/issues/43). Does anyone know where or not bazel coverage supports code coverage for py_tests and py_binaries?

Currently when I run the command 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

This provides me with blank coverage.dat files

I am looking for a way to use bazel coverage so that my tests will pass and a shared coverage.dat file will be generated with the combined coverage results of all tests that were ran. That way I can take the coverage.dat file and use that to generate an html report. Any help is greatly appreciated!!

1
  • Hello 4 years ago. you have to update to Bazel 6.0 better to get coverage. Commented Nov 16, 2023 at 9:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.