diff --git a/.bazelrc b/.bazelrc index 1ca15d116b1..481079770c2 100644 --- a/.bazelrc +++ b/.bazelrc @@ -226,6 +226,7 @@ coverage --instrument_test_targets coverage --define PL_COVERAGE=true coverage --copt -DPL_COVERAGE coverage --test_tag_filters=-requires_root,-requires_bpf,-no_coverage,-disabled,-no_gcc +coverage --action_env=COVERAGE_GCOV_OPTIONS=-b try-import %workspace%/bes.bazelrc diff --git a/.gitignore b/.gitignore index 00679518f01..0b5d53bd0b9 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,9 @@ user.bazelrc # A cache directory to be use by Bazel. .bazel-cache +# Coverage output file +coverage.info + # Arc liberate cache .phutil_module_cache diff --git a/ci/collect_coverage.sh b/ci/collect_coverage.sh index 151a87c57f7..ff9fead1f6c 100755 --- a/ci/collect_coverage.sh +++ b/ci/collect_coverage.sh @@ -138,6 +138,8 @@ check_config # Print config parameters. print_config +lcov_opts=(--rc lcov_branch_coverage=1) + cd $(bazel info workspace) # Get coverage from bazel targets. @@ -147,20 +149,20 @@ bazel coverage --remote_download_outputs=all --combined_report=lcov //src/... cp --no-preserve=mode "$(bazel info output_path)/_coverage/_coverage_report.dat" ${COVERAGE_FILE} # Print out the summary. -lcov --summary ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" --summary ${COVERAGE_FILE} # Remove test files from the coverage files. -lcov -r ${COVERAGE_FILE} '**/*_test.cc' -o ${COVERAGE_FILE} -lcov -r ${COVERAGE_FILE} '**/*_mock.cc' -o ${COVERAGE_FILE} -lcov -r ${COVERAGE_FILE} '**/*_mock.h' -o ${COVERAGE_FILE} -lcov -r ${COVERAGE_FILE} '**/*_test.go' -o ${COVERAGE_FILE} -lcov -r ${COVERAGE_FILE} '**/*.gen.go' -o ${COVERAGE_FILE} -lcov -r ${COVERAGE_FILE} '**/*-mock.tsx' -o ${COVERAGE_FILE} -lcov -r ${COVERAGE_FILE} '**/*-mock.ts' -o ${COVERAGE_FILE} -lcov -r ${COVERAGE_FILE} 'src/ui/src/types/generated/**' -o ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*_test.cc' -o ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*_mock.cc' -o ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*_mock.h' -o ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*_test.go' -o ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*.gen.go' -o ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*-mock.tsx' -o ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} '**/*-mock.ts' -o ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" -r ${COVERAGE_FILE} 'src/ui/src/types/generated/**' -o ${COVERAGE_FILE} # Print out the final summary. -lcov --summary ${COVERAGE_FILE} +lcov "${lcov_opts[@]}" --summary ${COVERAGE_FILE} # Upload to codecov.io. if [ "${UPLOAD_TO_CODECOV}" = true ]; then