Skip to content

C++ Coverage on MacOS is completely broken #10457

@ulfjack

Description

@ulfjack

Coverage with gcov:

  1. GCOV_PREFIX_STRIP is set incorrectly
    With a value of 3, the paths end up like this:
    bazel-testlogs/cpp/foo_test/_coverage/_bazel_ulfjack/312a82d9f5d7857ee9e5303755329142/sandbox/darwin-sandbox/4/execroot/main/bazel-out/darwin-fastbuild/bin/cpp/_objs/foo_test/main.gcda

The collect-coverage.sh script doesn't allow overriding GCOV_PREFIX_STRIP. I have a patch to not set it if it's already set in the test env. On this machine, I have to set it to 10.

  1. The latest gcov does not support the -i flag
    The -i flag is hard-coded in collect_cc_coverage.sh with no override possible.

  2. The gcov log uses lower-case "creating"
    The collect_cc_coverage.sh only checks for upper-case "Creating".

  3. The generated output is not in intermediate gcov format as expected by lcov_merger.

Coverage with llvm-profdata (--features=llvm_coverage_map_format):

  1. COVERAGE_GCOV_PATH is set to gcov
    This is obviously wrong. It needs to be set to llvm-profdata. However, llvm-profdata is not on the path, and there does not seem to be a way to override the location of gcov. I tried setting GCOV=/path/to/llvm-profdata before calling Bazel, but that had no effect.

  2. The lcov_merger simply copies the .profdata file to coverage.dat
    At least this allows users to post-process manually, but it's still unfortunate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-Rules-CPPIssues for C++ rulestype: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions