Skip to content

java_test and py_test do not collect cc_binary coverage #15098

@fmeum

Description

@fmeum

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)",
    },
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-Rules-JavaIssues for Java rulesteam-Rules-PythonNative rules for Pythontype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions