-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom test rule without _lcov_merger
attribute always fails under bazel coverage
#13978
Comments
I'm kinda surprised this ever worked before, I think the real core issue to fix is #10642 |
Since 5b216b2, all Starlark-defined test rules either need to set the `_lcov_merger` attribute or fail if run with `bazel coverage`. This is fixed by attaching the default lcov merger as a late-bound default to all Starlark rules via a new attribute and falling back to that attribute in the TestActionBuilder. This commit ensures backwards compatibility is maintained with existing Starlark test rules that set the `_lcov_merger` attribute. This is also verified in the included integration test. Fixes bazelbuild#13978.
Since 5b216b2, all Starlark-defined test rules either need to set the `_lcov_merger` attribute or fail if run with `bazel coverage`. This is fixed by attaching the default lcov merger as a late-bound default to all Starlark rules via a new attribute and falling back to that attribute in the TestActionBuilder. This commit ensures backwards compatibility is maintained with existing Starlark test rules that set the `_lcov_merger` attribute. This is also verified in the included integration test. Fixes bazelbuild#13978.
Since 5b216b2, all Starlark-defined test rules either need to set the `_lcov_merger` attribute or fail if run with `bazel coverage`. This is fixed by attaching the default lcov merger as a late-bound default to all Starlark rules via a new attribute and falling back to that attribute in the TestActionBuilder. This commit ensures backwards compatibility is maintained with existing Starlark test rules that set the `_lcov_merger` attribute. This is also verified in the included integration test. Fixes bazelbuild#13978.
Since 5b216b2, all Starlark-defined test rules either need to set the `_lcov_merger` attribute or fail if run with `bazel coverage`. This is fixed by attaching the default lcov merger as a late-bound default to all Starlark rules via a new attribute and falling back to that attribute in the TestActionBuilder. This commit ensures backwards compatibility is maintained with existing Starlark test rules that set the `_lcov_merger` attribute. This is also verified in the included integration test. Fixes bazelbuild#13978.
With that patch it does remove the need to pass |
A friendly 2 month ping on this. |
Can anyone send a PR to cherry-pick aa52f2d into release-5.0.0rc2? |
Rules that provide InstrumentedFilesInfo but do not define the _lcov_merger attribute will result in this script being called without the required LCOV_MERGER environment variable being set. Since _all_ rules now provide an InstrumentedFilesInfo provider by default, but are not required to provide the attribute, this scenario will be encountered far more frequently and should not be an error. Because of the way coverage collection within Google differs to Bazel, it isn't safe to change TestActionBuilder to simply not prepare the collect_coverage.sh script the way it would if no coverage was to be collected, so we have to change the script itself. Fixes bazelbuild#13978 Closes bazelbuild#14352. PiperOrigin-RevId: 413369871 (cherry picked from commit aa52f2d)
Rules that provide InstrumentedFilesInfo but do not define the _lcov_merger attribute will result in this script being called without the required LCOV_MERGER environment variable being set. Since _all_ rules now provide an InstrumentedFilesInfo provider by default, but are not required to provide the attribute, this scenario will be encountered far more frequently and should not be an error. Because of the way coverage collection within Google differs to Bazel, it isn't safe to change TestActionBuilder to simply not prepare the collect_coverage.sh script the way it would if no coverage was to be collected, so we have to change the script itself. Fixes #13978 Closes #14352. PiperOrigin-RevId: 413369871 (cherry picked from commit aa52f2d) Co-authored-by: Charles Mita <[email protected]>
Rules that provide InstrumentedFilesInfo but do not define the _lcov_merger attribute will result in this script being called without the required LCOV_MERGER environment variable being set. Since _all_ rules now provide an InstrumentedFilesInfo provider by default, but are not required to provide the attribute, this scenario will be encountered far more frequently and should not be an error. Because of the way coverage collection within Google differs to Bazel, it isn't safe to change TestActionBuilder to simply not prepare the collect_coverage.sh script the way it would if no coverage was to be collected, so we have to change the script itself. Fixes bazelbuild#13978 Closes bazelbuild#14352. PiperOrigin-RevId: 413369871
@meteorcloudy Hasn't this change in #14359 essentially made it so that any Starlark test rule not defining For example, using |
@meteorcloudy I didn't look into it much after #13983 was closed, but just at a glance, @mattem seems to have caught a real regression: I also think that tests executed with Should probably be marked as a release blocker for 5.0.1. |
Yeah, the
I can open a new issue if that's easier too. |
However, the alternative is that all these tests will now fail until the |
True, but in the current state, bazel 5.x is passing tests when they should be failing for those running coverage over their entire build. Is a reasonable workaround here to set |
Yes, both fail open and fail close are bad here, but I agree that fail open is even worse. I'm just saying that there is no obvious "fix forward" approach.
It would fix this issue, but would technically cause a regression from 5.0.0: The only way I am aware of that preserves backwards compatible with both 4.2.2 (fixing the regression) and 5.0.0 (not introducing a new regression) is to provide some default |
The |
Previously this short circuit meant the tests weren't actually run, and they would always exit 0, in the case the test rule didn't set the lcov related attributes. More context: bazelbuild#13978
Here's a fix #14807 |
Sorry for the delay in responding. #14807 looks to me to be an ok patch for this scenario, allowing us to proceed without regressing, but I'm not satisfied with how things are. |
Related #10642 |
Previously this short circuit meant the tests weren't actually run, and they would always exit 0, in the case the test rule didn't set the lcov related attributes. More context: #13978 Closes #14807. RELNOTES: Fixed an issue where Bazel could erroneously report a test passes in coverage mode without actually running the test. PiperOrigin-RevId: 428756211
Previously this short circuit meant the tests weren't actually run, and they would always exit 0, in the case the test rule didn't set the lcov related attributes. More context: bazelbuild#13978 Closes bazelbuild#14807. RELNOTES: Fixed an issue where Bazel could erroneously report a test passes in coverage mode without actually running the test. PiperOrigin-RevId: 428756211 (cherry picked from commit 16de035)
Previously this short circuit meant the tests weren't actually run, and they would always exit 0, in the case the test rule didn't set the lcov related attributes. More context: #13978 Closes #14807. RELNOTES: Fixed an issue where Bazel could erroneously report a test passes in coverage mode without actually running the test. PiperOrigin-RevId: 428756211 (cherry picked from commit 16de035) Co-authored-by: Keith Smiley <[email protected]>
I think that the fix is incomplete: Without |
Description of the problem / feature request:
When a custom Starlark test rule without explicit coverage support in the form of the
_lcov_merger
attribute is invoked viabazel coverage
with Bazel after 5b216b2, it fails withThe log says:
With Bazel 4.2.1, the build succeeds:
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
What operating system are you running Bazel on?
Linux
What's the output of
bazel info release
?release 5.0.0-pre.20210831.2
I bisected the origin of this issue back to 5b216b2.
Have you found anything relevant by searching the web?
With
5b216b27435aeb9eb9c3bd3c552d6498e1050cc7
, thecustom_test
rule in the reproducer now provides anInstrumentedFilesInfo
, which causes TestActionBuilder to collect coverage. However, since the rule does not have the:lcov_merger
attribute set, theLCOV_MERGER
env variable isn't set whencollect_coverage.sh
is invoked, which causes the error message reproduced above.The text was updated successfully, but these errors were encountered: