You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GCov does not exist at the given path: 'external/+cc_configure_extension+local_config_cc/wrapper/bin/msvc_nop.bat'
error: coverage collection script failed
As far as I remember Windows C++ coverage never worked and macOS is pretty fiddly to set up correctly. I think that they only fail in 9 since failures previously weren't fatal.
As far as I remember Windows C++ coverage never worked and macOS is pretty fiddly to set up correctly. I think that they only fail in 9 since failures previously weren't fatal.
I'm obviously a fan of coverage failing the action if there was an error (bazelbuild/bazel#18650) but my expectation was that those errors would be fixed before allowing coverage to fail actions. Would it be possible to add an incompatibility flag for this (defaulted to off) that allows silent failures and then allow users to flip it on (to expose errors) if they either only build on linux or a fix is rolled out?
--test_env=IGNORE_COVERAGE_COLLECTION_FAILURES=1 would sidestep that behavior if coverage was silently failing before, the assumption being that maybe instead you just shouldn't run bazel coverage and should swap to bazel test
Is coverage fully broken or is it just that the buildkite env isn't correctly setup for it? I think:
external/bazel_tools/tools/test/collect_cc_coverage.sh: line 99: : command not found
is a very bad error for a missing env var?
I opened this because I noticed the issue in rules_rust which I was upgrading to run Bazel 9 (bazelbuild/rules_rust#3867) and saw a cc_test fail with this issue. Seeing rules_cc CI fail with the same issue motivated me to start a discussion here.
ah yea that's an interesting case, sounds like coverage was working fine with some target types, but not cc_test, and so now they all have to work? either way that test_env is a good short term workaround
(21:14:42) INFO: From Testing //tests/runfiles:runfiles_test:
==================== Test output for //tests/runfiles:runfiles_test:
ERROR(tools/test/windows/tw.cc:1302) ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\b\i3qnbkwl\execroot\_main\bazel-out\x64_windows-fastbuild\bin\tests\runfiles\runfiles_test.exe.runfiles\_main\external\bazel_tools\tools\test\collect_coverage.sh" tests/runfiles/runfiles_test.exe): The system cannot find the file specified.
(error: 2)
ERROR(tools/test/windows/tw.cc:1479) Failed to start test process (arg: C:\b\i3qnbkwl\execroot\_main\bazel-out\x64_windows-fastbuild\bin\tests\runfiles\runfiles_test.exe.runfiles\_main\external\bazel_tools\tools\test\collect_coverage.sh)
================================================================================
(21:14:42) ERROR: C:/b/bk-windows-c1ns/bazel/rules-cc/tests/runfiles/BUILD:5:8: output 'tests/runfiles/runfiles_test/coverage.dat' was not created
(21:14:42) ERROR: C:/b/bk-windows-c1ns/bazel/rules-cc/tests/runfiles/BUILD:5:8: Testing //tests/runfiles:runfiles_test failed: not all outputs were created or valid
Separately, it looks like HEAD is broken for some tests. Should these tests be flagged as soft_fail: yes?
I'm not suggestion removing this from bazel. The script I referenced was collect_cc_coverage.sh which seemed both cc specific and like a fitting candidate to fork into rules_cc so changes can be made at a faster pace than the release of new Bazel versions.
If we move this into rules_cc, we force every ruleset with a *_test rule to add a dep on rules_cc to reference this script. Realistically speaking nobody would ever be able to run a real-world Bazel dep without a transitive dep on rules_cc, but ideally we wouldn't force that direct dep onto every ruleset.
The proper alternative would unfortunately require quite some design work: figure out a way to allow rulesets to register coverage hooks that run whenever these rulesets are in the transitive closure of a target.
That said, if we do it, we should not introduce an incompatible flag for this as the change should ideally be fully transparent. Wouldn't we just copy the script over, perhaps with fixes from the latest Bazel commits?
I still feel like folks aren't understanding what I'm saying
Leave all coverage scripts in bazelbuild/bazel alone
Add a collect_cc_coverage.sh script to bazelbuild/rules_cc
For rules in bazelbuild/rules_cc change the _collect_cc_coverage attribute to point to the new bazelbuild/rules_cc script.
No other rules are impacted, other rules can continue to either consume @bazel_tools//tools/test:collect_cc_coverage or replace it by defining the _collect_cc_coverage attribute. If rules_cc chooses to use a coverage collection script that lives within bazelbuild/rules_cc how does that have any impact on other rules?
There would likely be problems when the scripts diverge.
If there is a difference in the scripts, the rules_cc version would presumably be the "correct" one (since it should reflect the reality of the C++ rules), which means any test that transitively depends on C++ code (e.g. sh_test) should be using that version, which means it needs a dependency on it and thus rules_cc.
This doesn't mean I don't think collect_cc_coverage.sh belongs in rules_cc, but moving it there has implications for users and rule authors.
There would likely be problems when the scripts diverge.
If there is a difference in the scripts, the rules_cc version would presumably be the "correct" one (since it should reflect the reality of the C++ rules), which means any test that transitively depends on C++ code (e.g. sh_test) should be using that version, which means it needs a dependency on it and thus rules_cc.
This doesn't mean I don't think collect_cc_coverage.sh belongs in rules_cc, but moving it there has implications for users and rule authors.
Yeah, totally understand the consequences of copying collect_cc_coverage.sh to rules_cc in wanting to maintain parity between the two versions. But I think it'd ultimately be beneficial in being able to more quickly make improvements to it. Like, if the script lived here, and I ran into an issue, I would probably put up a pull-request and pull in the next BCR release. But with it living in Bazel, it's far more effort to make changes there and takes too long to come out. So instead I have to make a global change to add IGNORE_COVERAGE_COLLECTION_FAILURES=1 to all my test actions and potentially risk having issues silently ignored again which is kinda sad.
Presumably things that are broken for the cc rules that were silent/non-fatal before are problems for sh_test and friends, too, correct?
It sounds like the main concern is divergence, but not necessarily with a specific notion of incompatibility, just "these will diverge and rules_cc will be correct, therefore folks will want to use the rules_cc copy."
Could we have a new repo, "bazelbuild/coverage" or so that provides these scripts?
For older Bazels we could backport useful/interesting fixes.
I think that a separate coverage_support or even test_support module makes sense. We also need a place to host the tw.exe Windows test wrapper for cross-platform test runs.
cc @meteorcloudy Do you see value in moving the test runner to its own versioned module or would you prefer to keep it in bazel_tools?
Eventually, I would like to move things out of bazel_tools as much as possible (test runner, proto libraries, launchers, etcs). bazelbuild/bazel#28434
But for now, we don't have a good way to set up the release process of those smaller modules and I'm a bit afraid of the maintenance cost. @Wyverald I think we should probably plan this work next quarter or at least before Bazel 10.
I think if we want to move that script here we should just move it, remove it from bazel, and leave an alias in bazel for other consumers of it. I don't think that would cause any issues today (at least with 9.x+ where users would be forced to get a rules_cc version with the new file)
Activity
UebelAndre commentedon Feb 27, 2026
Maybe it would be worth-while to move @bazel_tools//tools/test/collect_cc_coverage.sh into
rules_cc?fmeum commentedon Feb 27, 2026
As far as I remember Windows C++ coverage never worked and macOS is pretty fiddly to set up correctly. I think that they only fail in 9 since failures previously weren't fatal.
UebelAndre commentedon Feb 27, 2026
I'm obviously a fan of coverage failing the action if there was an error (bazelbuild/bazel#18650) but my expectation was that those errors would be fixed before allowing coverage to fail actions. Would it be possible to add an incompatibility flag for this (defaulted to off) that allows silent failures and then allow users to flip it on (to expose errors) if they either only build on linux or a fix is rolled out?
UebelAndre commentedon Feb 27, 2026
For example,
rules_rusthas it's own coverage collection tool @rules_rust//util/collect_coverage/collect_coverage.rsfmeum commentedon Feb 27, 2026
@c-mita @keith
keith commentedon Mar 2, 2026
--test_env=IGNORE_COVERAGE_COLLECTION_FAILURES=1would sidestep that behavior if coverage was silently failing before, the assumption being that maybe instead you just shouldn't runbazel coverageand should swap tobazel testkeith commentedon Mar 2, 2026
Is coverage fully broken or is it just that the buildkite env isn't correctly setup for it? I think:
is a very bad error for a missing env var?
UebelAndre commentedon Mar 2, 2026
I opened this because I noticed the issue in
rules_rustwhich I was upgrading to run Bazel 9 (bazelbuild/rules_rust#3867) and saw acc_testfail with this issue. Seeingrules_ccCI fail with the same issue motivated me to start a discussion here.keith commentedon Mar 2, 2026
ah yea that's an interesting case, sounds like coverage was working fine with some target types, but not cc_test, and so now they all have to work? either way that test_env is a good short term workaround
UebelAndre commentedon Mar 2, 2026
I added
--test_env=IGNORE_COVERAGE_COLLECTION_FAILURES=1to #612 and interestingly there are still some issues though for Bazel 7:https://buildkite.com/bazel/rules-cc/builds/4778/steps/canvas?sid=019cb066-921f-4077-9bae-c562cd5e3afd
Separately, it looks like
HEADis broken for some tests. Should these tests be flagged assoft_fail: yes?UebelAndre commentedon Mar 2, 2026
@keith curious what your thoughts are on this. Seems like it could be a path to providing a more consistent behavior around coverage for
rules_cc?keith commentedon Mar 2, 2026
I think it would be fine to move, maybe a bit weird since it's so intertwined with the other bazel logic tho https://github.com/bazelbuild/bazel/blob/3bdf554c2ff9bbe90dabfdd4d38d8d132e7e61a1/tools/test/collect_coverage.sh#L195
UebelAndre commentedon Mar 3, 2026
I'm not suggestion removing this from
bazel. The script I referenced wascollect_cc_coverage.shwhich seemed both cc specific and like a fitting candidate to fork intorules_ccso changes can be made at a faster pace than the release of new Bazel versions.UebelAndre commentedon Mar 3, 2026
I filed #616 as a concrete example of what I'm thinking about
fmeum commentedon Mar 3, 2026
If we move this into rules_cc, we force every ruleset with a
*_testrule to add a dep on rules_cc to reference this script. Realistically speaking nobody would ever be able to run a real-world Bazel dep without a transitive dep on rules_cc, but ideally we wouldn't force that direct dep onto every ruleset.The proper alternative would unfortunately require quite some design work: figure out a way to allow rulesets to register coverage hooks that run whenever these rulesets are in the transitive closure of a target.
That said, if we do it, we should not introduce an incompatible flag for this as the change should ideally be fully transparent. Wouldn't we just copy the script over, perhaps with fixes from the latest Bazel commits?
5 remaining items
c-mita commentedon Mar 6, 2026
There would likely be problems when the scripts diverge.
If there is a difference in the scripts, the
rules_ccversion would presumably be the "correct" one (since it should reflect the reality of the C++ rules), which means any test that transitively depends on C++ code (e.g.sh_test) should be using that version, which means it needs a dependency on it and thusrules_cc.This doesn't mean I don't think
collect_cc_coverage.shbelongs inrules_cc, but moving it there has implications for users and rule authors.UebelAndre commentedon Mar 6, 2026
Yeah, totally understand the consequences of copying
collect_cc_coverage.shtorules_ccin wanting to maintain parity between the two versions. But I think it'd ultimately be beneficial in being able to more quickly make improvements to it. Like, if the script lived here, and I ran into an issue, I would probably put up a pull-request and pull in the next BCR release. But with it living in Bazel, it's far more effort to make changes there and takes too long to come out. So instead I have to make a global change to addIGNORE_COVERAGE_COLLECTION_FAILURES=1to all my test actions and potentially risk having issues silently ignored again which is kinda sad.trybka commentedon Mar 23, 2026
Presumably things that are broken for the cc rules that were silent/non-fatal before are problems for
sh_testand friends, too, correct?It sounds like the main concern is divergence, but not necessarily with a specific notion of incompatibility, just "these will diverge and rules_cc will be correct, therefore folks will want to use the rules_cc copy."
Could we have a new repo, "bazelbuild/coverage" or so that provides these scripts?
For older Bazels we could backport useful/interesting fixes.
Thoughts? @c-mita @fmeum @keith ?
UebelAndre commentedon Mar 24, 2026
For the record, #656 contains no fixes. It's just removing flags from CI that previously silenced the issues.
UebelAndre commentedon Mar 30, 2026
@c-mita @fmeum @keith ping on #613 (comment)
fmeum commentedon Mar 30, 2026
I think that a separate
coverage_supportor eventest_supportmodule makes sense. We also need a place to host thetw.exeWindows test wrapper for cross-platform test runs.cc @meteorcloudy Do you see value in moving the test runner to its own versioned module or would you prefer to keep it in
bazel_tools?meteorcloudy commentedon Mar 30, 2026
Eventually, I would like to move things out of bazel_tools as much as possible (test runner, proto libraries, launchers, etcs). bazelbuild/bazel#28434
But for now, we don't have a good way to set up the release process of those smaller modules and I'm a bit afraid of the maintenance cost. @Wyverald I think we should probably plan this work next quarter or at least before Bazel 10.
keith commentedon Mar 30, 2026
I think if we want to move that script here we should just move it, remove it from bazel, and leave an alias in bazel for other consumers of it. I don't think that would cause any issues today (at least with 9.x+ where users would be forced to get a rules_cc version with the new file)
UebelAndre commentedon Mar 31, 2026
@trybka your thoughts on the responses? I also don’t know who has final say here.
Add coverage collection script from upstream Bazel.
Fix coverage with MacOS autoconf toolchains
pzembrod commentedon Aug 28, 2026
@c-mita Do you know what the latest status on this is, after your recent coverage work?