`bazel run --collect_coverage //some:test` doesn't generate required `collect_coverage` script
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
When you use `bazel run` on a test target, along with `--collect_coverage`, the required `collect_coverage` script isn't generated even though it's used. It seems like it's not properly added as a run file.
### Which category does this issue belong to?
Core
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
```
$ bazel clean
$ bazel run --collect_coverage //some:test
exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //some:test
-----------------------------------------------------------------------------
external/bazel_tools/tools/test/test-setup.sh: line 339: bazel-out/darwin_arm64-opt-exec-ST-e0b77ff00d50/bin/external/bazel_tools/tools/test/collect_coverage: No such file or directory
```
### Which operating system are you running Bazel on?
macOS 26.3
### What is the output of `bazel info release`?
release 8.5.1
### 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` ?
```text
```
### 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_
Contributor guide
Research direction
Start by reproducing the command `bazel run --collect_coverage //some:test` and inspect `external/bazel_tools/tools/test/test-setup.sh` around line 339, where the missing script is used. Trace how the `collect_coverage` script is added to run files, then verify that the command completes without the reported missing-file error.
Written by the indexing model from the issue text.
Assessment
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100