-
-
Notifications
You must be signed in to change notification settings - Fork 636
Closed
Description
π bug report
Affected Rule
py_test
Is this a regression?
Not that I'm aware of.
Description
bazel coverage fails without any useful messages when some Python packages are being used/imported. Some examples:
torchvisiontransformers.models.distilbert.DistilBertModel
π¬ Minimal Reproduction
See https://github.com/BurnzZ/bazel-python-coverage-issue for the full code example.
- Clone the repo:
git clone https://github.com/BurnzZ/bazel-python-coverage-issue
cd bazel-python-coverage-issue
- Open
test.pyand uncomment either of these lines:
# import torchvision
# from transformers.models.distilbert import DistilBertModel- Run the following:
bazel coverage --combined_report=lcov :test --nocache_test_results --test_output=all
lcov --list "$(bazel info output_path)/_coverage/_coverage_report.dat"
-
Notice that test coverage fails without useful context or error messages.
-
Run the following and notice that the code should run successfully when tested:
bazel test :test --nocache_test_results --test_output=all
Try commenting out the imports above and run bazel coverage and it should work. Curious as to why it doesn't work in some package like torchvision or some parts of transformers.
π₯ Exception or Error
$ bazel coverage --combined_report=lcov :test --nocache_test_results --test_output=all
INFO: Using default value for --instrumentation_filter: "^//".
INFO: Override the above default with --instrumentation_filter
INFO: Analyzed target //:test (0 packages loaded, 0 targets configured).
FAIL: //:test (Exit 1) (see /private/var/tmp/_bazel_user/c97d0f59e3791eddf9709b879355cbf5/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/test/test.log)
INFO: From Testing //:test:
==================== Test output for //:test:
--
Coverage runner: Not collecting coverage for failed test.
The following commands failed with status 1
/private/var/tmp/_bazel_user/c97d0f59e3791eddf9709b879355cbf5/sandbox/darwin-sandbox/7/execroot/_main/bazel-out/darwin_arm64-fastbuild/bin/test.runfiles/_main/test
================================================================================
INFO: LCOV coverage report is located at /private/var/tmp/_bazel_user/c97d0f59e3791eddf9709b879355cbf5/execroot/_main/bazel-out/_coverage/_coverage_report.dat
and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: From Coverage report generation:
Jan. 23, 2025 4:55:51 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: Found 1 tracefiles.
Jan. 23, 2025 4:55:51 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file bazel-out/darwin_arm64-fastbuild/testlogs/test/coverage.dat
Jan. 23, 2025 4:55:51 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: No gcov info file found.
Jan. 23, 2025 4:55:51 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Jan. 23, 2025 4:55:51 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
Jan. 23, 2025 4:55:51 PM com.google.devtools.coverageoutputgenerator.Main runWithArgs
WARNING: There was no coverage found.
INFO: Found 1 test target...
Target //:test up-to-date:
bazel-bin/test
INFO: Elapsed time: 14.578s, Critical Path: 14.22s
INFO: 3 processes: 2 action cache hit, 3 darwin-sandbox.
INFO: Build completed, 1 test FAILED, 3 total actions
//:test FAILED in 13.7s
/private/var/tmp/_bazel_user/c97d0f59e3791eddf9709b879355cbf5/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/test/test.log
Executed 1 out of 1 test: 1 fails locally.
$ lcov --list "$(bazel info output_path)/_coverage/_coverage_report.dat"
lcov: ERROR: (empty) no valid records found in tracefile /private/var/tmp/_bazel_user/c97d0f59e3791eddf9709b879355cbf5/execroot/_main/bazel-out/_coverage/_coverage_report.dat
(use "lcov --ignore-errors empty ..." to bypass this error)
π Your Environment
Operating System:
MacBook Sequoia 15.2
Output of bazel version:
8.0.1
Also tried 7.4.1
Rules_python version:
1.1.0
jesses-canva
Metadata
Metadata
Assignees
Labels
No labels