bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.2k stars 4.06k forks source link

dangling symbolic link with `--experimental_fetch_all_coverage_outputs` #23718

Open oliverlee opened 1 month ago

oliverlee commented 1 month ago

Description of the bug:

I am trying to retain the .gcov files from running coverage and am using --experimental_fetch_all_coverage_outputs mentioned here. When I run the coverage command, I get an error

Sep 23, 2024 5:49:19 PM com.google.devtools.coverageoutputgenerator.Main getTracefiles
INFO: No lcov file found.
Sep 23, 2024 5:49:19 PM com.google.devtools.coverageoutputgenerator.Main getGcovInfoFiles
INFO: Found 1 gcov info files.
Sep 23, 2024 5:49:19 PM com.google.devtools.coverageoutputgenerator.Main parseFilesSequentially
INFO: Parsing file /private/var/tmp/_bazel_oliver/428b4df1ffa12884ed645567c097dd18/sandbox/darwin-sandbox/37/execroot/coverage-example/bazel-out/darwin_arm64-fastbuild/testlogs/test/lib_test/_coverage/_cc_coverage.gcov
Sep 23, 2024 5:49:19 PM com.google.devtools.coverageoutputgenerator.Main getGcovJsonInfoFiles
INFO: No gcov json file found.
Sep 23, 2024 5:49:19 PM com.google.devtools.coverageoutputgenerator.Main getProfdataFileOrNull
INFO: No .profdata file found.
================================================================================
ERROR: /Users/oliver/repos/basic-coverage-example/test/BUILD.bazel:1:8: Error while validating output TreeArtifact File:[[<execution_root>]bazel-out/darwin_arm64-fastbuild/testlogs]test/lib_test/_coverage : Child gcov of tree artifact /private/var/tmp/_bazel_oliver/428b4df1ffa12884ed645567c097dd18/execroot/coverage-example/bazel-out/darwin_arm64-fastbuild/testlogs/test/lib_test/_coverage is a dangling symbolic link
ERROR: /Users/oliver/repos/basic-coverage-example/test/BUILD.bazel:1:8: Testing //test:lib_test failed: not all outputs were created or valid

Which category does this issue belong to?

No response

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

clone https://github.com/oliverlee/basic-coverage-example and run:

bazel coverage //... --instrumentation_filter=//:lib --config=gcov --experimental_fetch_all_coverage_outputs

Which operating system are you running Bazel on?

macOS 14.6

What is the output of bazel info release?

7.1.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

oliverlee commented 1 month ago

It does appear that all gcda files are available if --keep_going is passed to coverage:

❯  fd --no-ignore gcda bazel-testlogs | wc -l
     304