-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Make coverage collection more resilient to test failure #26324
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
base: master
Are you sure you want to change the base?
Conversation
I don't think this would be a good idea, at least not without some more thought. Something similar was tried internally a while back and had to be reverted. There are a couple of issues that come to mind:
Annoying though it may be, this is "Working as intended". |
Some more context, fwiw: This change was requested by the developers at my firm years ago, and they have been using it in our Bazel fork happily ever since. I was only just now able to upstream the patch. This patch is intended to improve the local development experience. For example, when you are refactoring a class, while running something like Note also that with this patch, in the case that any test fails, the runner still tells you this in the output, and critically, Bazel still exits nonzero. So this should not affect anything that actually checks for the success of the I think the above mitigates the following concern:
As well as this one:
During local development, the developer sees which tests failed, and can treat the resulting coverage data appropriately. This is especially useful when using Bazel with a coverage tool that shows you which tests covered which lines. Without this patch, the coverage data isn't even collected, so the developer doesn't even have the chance to decide. Outside local development, e.g. in CI, the failure of a test means the corresponding patch should not be merged, so the coverage data should be ignored in the first place.
I would be curious to hear more of that story (I don't think it overlapped with my time at Google), and appreciate your openness to giving this more thought. Hope the context I gave above is helpful. |
`bazel coverage foo` runs the tests in target `foo` and collects resulting code coverage. Note there may be arbitrarily many tests defined in target `foo`. Without the changes in this commit, if only one of the tests in `foo` fails, it defeats coverage collection for all other tests in that target. This is fixed by deferring the `exit $TEST_STATUS` call to run after `$LCOV_MERGER_CMD` is run.
42f6e87
to
7333bef
Compare
I see how this can be useful, but we need to be careful with the combined report (I believe that's what @c-mita is worried about). The report should not merge on coverage from failing tests. Since it's generated only after all tests have completed, this should be doable though. |
Without these changes,
bazel coverage foo
does not collect coverage for any of the tests in thefoo
target if even a single test in that target fails. A failing test infoo
should not defeat coverage collection for all the tests in that target.This is easily fixed by deferring the
exit $TEST_STATUS
call to run after$LCOV_MERGER_CMD
is run.