Closed
Description
π bug report
Affected Rule
bazel coverage
Is this a regression?
Not sureDescription
bazel test
passed and bazel coverage
failed.
We use pytest tmpdir
to create temporary directory for one of the test cases during execution and it is assumed to be removed after the test cases finished automatically. It seems bazel coverage is trying to find the source file for the files in temporary directory which it shouldn't. It will throw "no source file found" error and this prevents generating coverage report.
Also, Is there a workaround to ignore "no source for code" error?
bazel coverage --instrument_test_targets=false --test_output=streamed --verbose_failures --action_env=VERBOSE_COVERAGE=true --sandbox_debug --java_runtime_version=remotejdk_11
//:common_tools_test
Logs:
INFO: Invocation ID: eed41e0b-978a-4c79-8437-16ddaceb1224
WARNING: Streamed test output requested. All tests will be run locally, without sharding, one at a time
INFO: Using default value for --instrumentation_filter: "^//".
INFO: Override the above default with --instrumentation_filter
INFO: Analyzed target //:common_tools_test (1 packages loaded, 20 targets configured).
INFO: Found 1 test target...
+ [[ -z bazel-out/darwin-fastbuild/bin/common_tools_test.instrumented_files ]]
+ export ROOT=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__
+ ROOT=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__
+ [[ bazel-out/darwin-fastbuild/bin/common_tools_test.instrumented_files != /* ]]
+ export COVERAGE_MANIFEST=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/bin/common_tools_test.instrumented_files
+ COVERAGE_MANIFEST=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/bin/common_tools_test.instrumented_files
+ export COVERAGE_DIR=bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test
+ COVERAGE_DIR=bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test
+ [[ bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test == /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__* ]]
+ COVERAGE_DIR=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test
+ mkdir -p /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test
+ COVERAGE_OUTPUT_FILE=bazel-out/darwin-fastbuild/testlogs/common_tools_test/coverage.dat
+ [[ bazel-out/darwin-fastbuild/testlogs/common_tools_test/coverage.dat == /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__* ]]
+ COVERAGE_OUTPUT_FILE=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/common_tools_test/coverage.dat
+ export JAVA_COVERAGE_FILE=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test/jvcov.dat
+ JAVA_COVERAGE_FILE=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test/jvcov.dat
+ export COVERAGE=1
+ COVERAGE=1
+ export BULK_COVERAGE_RUN=1
+ BULK_COVERAGE_RUN=1
+ [[ -z '' ]]
+ export GCOV_PREFIX_STRIP=3
+ GCOV_PREFIX_STRIP=3
+ export GCOV_PREFIX=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test
+ GCOV_PREFIX=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test
+ export LLVM_PROFILE_FILE=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test/%h-%p-%m.profraw
+ LLVM_PROFILE_FILE=/private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test/%h-%p-%m.profraw
+ [[ -n '' ]]
+ [[ ! -z '' ]]
+ [[ 0 == \0 ]]
+ cd /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/bin/common_tools_test.runfiles/__main__
+ [[ 0 == \0 ]]
+ touch /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/common_tools_test/coverage.dat
+ /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/bin/common_tools_test.runfiles/__main__/common_tools_test '--junit-xml=$XML_OUTPUT_FILE' --ignore=external
Using toolchain coverage_tool 'python311_x86_64-apple-darwin_coverage/coverage/__main__.py'
Coverage entrypoint: /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/bin/common_tools_test.runfiles/python311_x86_64-apple-darwin_coverage/coverage/__main__.py
============================= test session starts ==============================
platform darwin -- Python 3.11.1, pytest-7.3.1, pluggy-1.0.0
rootdir: /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/bin/common_tools_test.runfiles/__main__
collected 44 items
test/common_tools/test_cli.py ...... [ 13%]
test/common_tools/test_common.py .. [ 18%]
test/common_tools/test_config.py ........................ [ 72%]
test/common_tools/test_ownership.py ....... [ 88%]
test/common_tools/test_testing.py ..... [100%]
- generated xml file: /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/common_tools_test/test.xml -
============================== 44 passed in 2.79s ==============================
Converting coveragepy database to lcov: /private/var/tmp/_bazel_nlou/b43af9baf9d056244183c6c3d6dd8487/sandbox/darwin-sandbox/19/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/_coverage/common_tools_test/test/pylcov.dat
No source for code: '/private/var/folders/6m/nl3wnqp96hz5b53qpx2y71f40000gp/T/pytest-of-nlou/pytest-313/test_load_config_from_fs0/dev/github.json'.
<=============== created by `pytest tmpdir`
+ TEST_STATUS=1
+ [[ 1 -ne 0 ]]
+ echo --
--
+ echo Coverage runner: Not collecting coverage for failed test.
Coverage runner: Not collecting coverage for failed test.
+ echo The following commands failed with status 1
π¬ Minimal Reproduction
π₯ Exception or Error
π Your Environment
Operating System:
darwin macos
Output of bazel version
:
bazel 6.1.1
Rules_python version:
python_register_toolchains(
name = "python311",
python_version = "3.11",
register_coverage_tool = True,
)
Anything else relevant?