Replace virtual includes generated paths with their actual paths in the coverage reports. Fixes #6254. RELNOTES: The code coverage report now includes the actual paths to header files instead of the ugly, Bazel generated, virtual includes path. For example, the `SF:` (source file) lines in the coverage report now look like this: ``` SF:include/common/strategy.h ``` instead of ``` SF:bazel-out/k8-fastbuild/bin/include/common/_virtual_includes/strategy/strategy.h ``` Closes #6372. PiperOrigin-RevId: 219112911
diff --git a/tools/test/collect_coverage.sh b/tools/test/collect_coverage.sh index bcdf8fd..a31e083 100755 --- a/tools/test/collect_coverage.sh +++ b/tools/test/collect_coverage.sh
@@ -103,6 +103,7 @@ eval "${CC_CODE_COVERAGE_SCRIPT}" fi + # Export the command line that invokes LcovMerger with the flags: # --coverage_dir The absolute path of the directory where the # intermediate coverage reports are located. @@ -124,7 +125,7 @@ # keep only the C++ sources found in the manifest. # For other languages the sources in the manifest are # ignored. -export LCOV_MERGER_CMD="${LCOV_MERGER} --coverage_dir=${COVERAGE_DIR} \ +LCOV_MERGER_CMD="${LCOV_MERGER} --coverage_dir=${COVERAGE_DIR} \ --output_file=${COVERAGE_OUTPUT_FILE} \ --filter_sources=/usr/bin/.+ \ --filter_sources=/usr/lib/.+ \ @@ -132,6 +133,10 @@ --filter_sources=.*external/.+ \ --source_file_manifest=${COVERAGE_MANIFEST}" +if [[ $COVERAGE_REPORTED_TO_ACTUAL_SOURCES_FILE ]]; then + LCOV_MERGER_CMD="$LCOV_MERGER_CMD\ + --sources_to_replace_file=$ROOT/$COVERAGE_REPORTED_TO_ACTUAL_SOURCES_FILE" +fi if [[ $DISPLAY_LCOV_CMD ]] ; then echo "Running lcov_merger"