-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Coverage on macOS doesn't filter out system headers #14969
Copy link
Copy link
Closed
Labels
Description
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 //:testThe 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?
Reactions are currently unavailable