I have the pytest file called sample_unit_test.py
and BUILD.bazel
mentioning the target and other details. When I run bazel test //folder_path:sample_unit_test
, it is passing the test but when I run bazel coverage
with the same target failing with the following error:
LCOV_MERGER_CMD='bazel-out/k8-opt/bin/external/remote_coverage_tools/Main --coverage_dir=/worker/build/89bf270e28a51440/root/_coverage/<mypath>/_test/test --output_file=/worker/build/89bf270e28a51440/root/bazel-out/k8-opt/testlogs/<some_path>/coverage.dat --filter_sources=/usr/bin/.+ --filter_sources=/usr/lib/.+ --filter_sources=/usr/include.+ --filter_sources=/Applications/.+ --filter_sources=.*external/.+ --source_file_manifest=/worker/build/89bf270e28a51440/root/bazel-out/k8-opt/bin/<some_path>.instrumented_files'
+ [[ -n '' ]]
+ [[ -n '' ]]
+ JAVA_RUNFILES=
+ exec bazel-out/k8-opt/bin/external/remote_coverage_tools/Main --coverage_dir=/worker/build/89bf270e28a51440/root/_coverage/<mypath>_unit_test/test --output_file=/worker/build/89bf270e28a51440/root/bazel-out/k8-opt/testlogs/<mypath>/coverage.dat --filter_sources=/usr/bin/.+ --filter_sources=/usr/lib/.+ --filter_sources=/usr/include.+ --filter_sources=/Applications/.+ '--filter_sources=.*external/.+' --source_file_manifest=/worker/build/89bf270e28a51440/root/bazel-out/k8-opt/bin/<some_path>_unit_test.instrumented_files
/worker/build/89bf270e28a51440/root/bazel-out/k8-opt/bin/external/remote_coverage_tools/Main: Cannot locate runfiles directory. (Set $JAVA_RUNFILES to inhibit searching.)
Action details (cached result): <some_link>
Exact command: bazel coverage --test_env=PYTHON_COVERAGE=/usr/local/bin/coverage --test_env=COVERAGE_GCOV_PATH=/usr/bin/gcov //<path>:sample_unit_test --keep_going
\
How and What do I set $JAVA_RUNFILES
? If bazel test is able to auto set this variable then why bazel coverage is struggling?
Please help.
Your help would be immensely appreciated. Thank you
System Configuration:
Bazel version: 5.4.0 (I can't update Bazel because of other dependency)
OS: Ubuntu