Skip to content
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

Add _lcov_merger attribute to test rules #691

Closed
wants to merge 1 commit into from

Conversation

keith
Copy link
Member

@keith keith commented Jan 14, 2020

This is required to use --combined_report=lcov with bazel coverage

This is required to use `--combined_report=lcov` with `bazel coverage`
@allevato
Copy link
Member

It's a bit more complicated than this. Based on bazelbuild/bazel#8477, we would also want this to be a late-bound default so that it only applies for coverage-enabled builds; otherwise, regular bazel {build,test} invocations also incur the cost of processing the lcov_merger dependency.

I wish it was clearer why every test rule needs to have a dependency on this tool instead of it just being something that Bazel handles on its own. I guess because it has to run the tool in the scope of the test action? If this is meant to be a supported path for coverage, there's no documentation about lcov_merger or the attribute on Bazel's site yet to indicate that.

Another oddity is that Bazel's definition of cc_test (BazelCcTestRule.java) is a separate implementation from the one we use in Google, and the Google one does not set the [:$_]lcov_merger attribute (nor do any of our other test rules), but coverage still works with Blaze. But, as far as I can tell, the TestActionBuilder.java code that references that attribute is the same in both Bazel and Blaze, and we do use lcov_merger internally, so it just gets into the build "some other way."

I'd like to understand why that "some other way" wasn't feasible for Bazel, because if we do have to add this for Bazel to support coverage, we'll also need to update our workflows to exclude the attribute from our internal version of the rules since it's not needed (and could potentially conflict with other stuff Blaze is doing).

@keith
Copy link
Member Author

keith commented Jan 14, 2020

We talked offline a bit here and we're going to try and find some way to late bind this attribute, since there doesn't seem to be an API to do this at the moment based on whether or not coverage is enabled.

@keith
Copy link
Member Author

keith commented Jan 23, 2020

Filed an issue for discussion here bazelbuild/bazel#10642

@keith keith mentioned this pull request Apr 28, 2020
@keith
Copy link
Member Author

keith commented Aug 10, 2020

For now the suggested workaround is to use --test_env=LCOV_MERGER=/usr/bin/true

@keith keith closed this Aug 10, 2020
@keith keith deleted the ks/add-lcov-merger branch August 10, 2020 23:24
@keith keith restored the ks/add-lcov-merger branch March 12, 2022 01:31
@keith keith deleted the ks/add-lcov-merger branch March 12, 2022 01:32
keith added a commit that referenced this pull request Mar 12, 2022
As of bazel 5.1 this can be used as a late bound attribute bazelbuild/bazel@14d8be0

This alleviates the concerns from
#691 and allows users to
use this feature, and avoid having to pass `LCOV_MERGER` in the
environment manually
keith added a commit that referenced this pull request Apr 16, 2022
As of bazel 5.1 this can be used as a late bound attribute bazelbuild/bazel@14d8be0

This alleviates the concerns from
#691 and allows users to
use this feature, and avoid having to pass `LCOV_MERGER` in the
environment manually
keith added a commit that referenced this pull request Jul 7, 2022
As of bazel 5.1 this can be used as a late bound attribute bazelbuild/bazel@14d8be0

This alleviates the concerns from
#691 and allows users to
use this feature, and avoid having to pass `LCOV_MERGER` in the
environment manually
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants