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

java_test and py_test do not collect cc_binary coverage #15098

Closed
fmeum opened this issue Mar 22, 2022 · 3 comments
Closed

java_test and py_test do not collect cc_binary coverage #15098

fmeum opened this issue Mar 22, 2022 · 3 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules team-Rules-Python Native rules for Python type: bug

Comments

@fmeum
Copy link
Collaborator

fmeum commented Mar 22, 2022

Description of the problem / feature request:

Any java_test or py_test that executes a cc_binary at runtime will not report coverage for the cc_binary's sources.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Reproducers are available as integration tests for Java and Python.

What operating system are you running Bazel on?

Linux

What's the output of bazel info release?

5.0.0, 5.1.0rc3 (but also affects HEAD)

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

I submitted fixes as #15096 (Java) and #15097 (Python).

Individual test targets can work around this issue by adding:

*_test(
    ...,
    data = [
        ...,
        "@bazel_tools//tools/test:collect_cc_coverage.sh"
    ],
    env = {
        ...,
        "CC_CODE_COVERAGE_SCRIPT": "$$RUNFILES_DIR/$$TEST_WORKSPACE/$(execpath @bazel_tools//tools/test:collect_cc_coverage.sh)",
    },
)
@sgowroji sgowroji added team-Rules-Java Issues for Java rules untriaged team-Rules-Python Native rules for Python labels Mar 22, 2022
@comius comius added type: bug P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Mar 23, 2022
@comius comius removed their assignment Mar 23, 2022
bazel-io pushed a commit that referenced this issue Apr 1, 2022
Before this commit, if a java_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelJavaTestRule, similar to how this is already done for
BazelShTestRule.

Fixes the Java part of #15098.

Closes #15096.

PiperOrigin-RevId: 438785232
@fmeum
Copy link
Collaborator Author

fmeum commented Apr 12, 2022

@bazel-io fork 5.2.0

fmeum added a commit to fmeum/bazel that referenced this issue Apr 12, 2022
Before this commit, if a java_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelJavaTestRule, similar to how this is already done for
BazelShTestRule.

Fixes the Java part of bazelbuild#15098.

Closes bazelbuild#15096.

PiperOrigin-RevId: 438785232
fmeum added a commit to fmeum/bazel that referenced this issue Apr 12, 2022
Before this commit, if a java_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelJavaTestRule, similar to how this is already done for
BazelShTestRule.

Fixes the Java part of bazelbuild#15098.

Closes bazelbuild#15096.

PiperOrigin-RevId: 438785232
@brentleyjones
Copy link
Contributor

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Apr 13, 2022
fmeum added a commit to fmeum/bazel that referenced this issue Apr 13, 2022
Before this commit, if a java_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelJavaTestRule, similar to how this is already done for
BazelShTestRule.

Fixes the Java part of bazelbuild#15098.

Closes bazelbuild#15096.

PiperOrigin-RevId: 438785232
@ckolli5
Copy link

ckolli5 commented Apr 13, 2022

@bazel-io fork 5.2.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Apr 13, 2022
fmeum added a commit to fmeum/bazel that referenced this issue Apr 19, 2022
Before this commit, if a java_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelJavaTestRule, similar to how this is already done for
BazelShTestRule.

Fixes the Java part of bazelbuild#15098.

Closes bazelbuild#15096.

PiperOrigin-RevId: 438785232
fmeum added a commit to fmeum/bazel that referenced this issue Apr 20, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes bazelbuild#15098.

Closes bazelbuild#15097.

PiperOrigin-RevId: 442800790
fmeum added a commit to fmeum/bazel that referenced this issue Apr 20, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes bazelbuild#15098.

Closes bazelbuild#15097.

PiperOrigin-RevId: 442800790
fmeum added a commit to fmeum/bazel that referenced this issue Apr 21, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes bazelbuild#15098.

Closes bazelbuild#15097.

PiperOrigin-RevId: 442800790
fmeum added a commit to fmeum/bazel that referenced this issue Apr 21, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes bazelbuild#15098.

Closes bazelbuild#15097.

PiperOrigin-RevId: 442800790
fmeum added a commit to fmeum/bazel that referenced this issue Apr 21, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes bazelbuild#15098.

Closes bazelbuild#15097.

PiperOrigin-RevId: 442800790
fmeum added a commit to fmeum/bazel that referenced this issue Apr 21, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes bazelbuild#15098.

Closes bazelbuild#15097.

PiperOrigin-RevId: 442800790
ckolli5 pushed a commit that referenced this issue May 9, 2022
Before this commit, if a java_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelJavaTestRule, similar to how this is already done for
BazelShTestRule.

Fixes the Java part of #15098.

Closes #15096.

PiperOrigin-RevId: 438785232
fmeum added a commit to fmeum/bazel that referenced this issue May 10, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes bazelbuild#15098.

Closes bazelbuild#15097.

PiperOrigin-RevId: 442800790
fmeum added a commit to fmeum/bazel that referenced this issue May 12, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes bazelbuild#15098.

Closes bazelbuild#15097.

PiperOrigin-RevId: 442800790
ckolli5 added a commit that referenced this issue May 12, 2022
Before this commit, if a py_test executed a cc_binary from its data
deps, coverage for this cc_binary would not be collected. This is fixed
by adding the implicit `$collect_cc_coverage` attribute to
BazelPyTestRule, similar to how this is already done for
BazelShTestRule.

Fixes #15098.

Closes #15097.

PiperOrigin-RevId: 442800790

Co-authored-by: Chenchu Kolli <ckolli@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules team-Rules-Python Native rules for Python type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants