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

Coverage on macOS doesn't filter out system headers #14969

Closed
phst opened this issue Mar 5, 2022 · 1 comment
Closed

Coverage on macOS doesn't filter out system headers #14969

phst opened this issue Mar 5, 2022 · 1 comment
Labels

Comments

@phst
Copy link
Contributor

phst commented Mar 5, 2022

Description of the problem / feature request:

The coverage.dat file produced on macOS contains entries for system headers in /Applications.

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

BUILD file:

cc_test(
    name = "test",
    srcs = ["test.cc"],
    deps = [":lib"],
)

cc_library(
    name = "lib",
    srcs = ["lib.cc"],
    hdrs = ["lib.h"],
)

lib.h:

extern void Function();

lib.cc:

#include "lib.h"
#include <iostream>
void Function() {
  std::cout << "hello world" << std::endl;
}

test.cc:

#include "lib.h"
int main() {
  Function();
}

Then, run

bazel --nohome_rc --nosystem_rc --noworkspace_rc --bazelrc=/dev/null coverage \
  --test_env=VERBOSE_COVERAGE=1 --test_env=GCOV_PREFIX_STRIP=10 \
  --test_output=all --nocache_test_results //:test

The GCOV_PREFIX_STRIP is for #10457.

The resulting coverage file will contain lots of data for C++ standard headers residing in the /Applications directory.
Probably that directory can simply be added to https://github.com/bazelbuild/bazel/blob/5.0.0/tools/test/collect_coverage.sh#L232, because it's very unlikely that someone will have a Bazel workspace in /Applications.

What operating system are you running Bazel on?

macOS 12.2.1

What's the output of bazel info release?

release 5.0.0-homebrew

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

Nothing (not in a Git repository)

Have you found anything relevant by searching the web?

#10457 is somewhat related (albeit a bit pessimistic; coverage on macOS does work in general), but doesn't seem to touch on this specific bug.

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

logs.zip

phst added a commit to phst/rules_elisp that referenced this issue Mar 5, 2022
phst added a commit to phst/bazel that referenced this issue Mar 5, 2022
@brentleyjones
Copy link
Contributor

@bazel-io fork 5.1

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 a pull request may close this issue.

3 participants