@@ -28,9 +28,7 @@ GENERATE_HTML=false
2828UPLOAD_TO_CODECOV=false
2929HTML_OUTPUT_DIR=" "
3030
31- CC_COVERAGE_FILE=" cc_coverage.info"
32- GO_COVERAGE_FILE=" coverage.txt"
33- UI_OUTPUT=bazel-testlogs/src/ui/ui-tests/coverage.dat
31+ COVERAGE_FILE=" coverage.info"
3432
3533# Print out the usage information and exit.
3634usage () {
@@ -121,16 +119,11 @@ parse_args() {
121119}
122120
123121generate_html () {
124- genhtml -o ${HTML_OUTPUT_DIR} -s ${CC_COVERAGE_FILE}
125-
126- echo " ****************************************************"
127- echo " * For Go HTML do the following: "
128- echo " * go tool cover -html=${GO_COVERAGE_FILE} "
129- echo " ****************************************************"
122+ genhtml -o " ${HTML_OUTPUT_DIR} " -s ${COVERAGE_FILE}
130123}
131124
132125upload_to_codecov () {
133- codecov -t " ${CODECOV_TOKEN} " -B " ${GIT_BRANCH} " -C " ${GIT_COMMIT} " -r " ${GIT_REPO} " -f " ${CC_COVERAGE_FILE} " -f " ${GO_COVERAGE_FILE} " -f " ${UI_OUTPUT }"
126+ codecov -t " ${CODECOV_TOKEN} " -B " ${GIT_BRANCH} " -C " ${GIT_COMMIT} " -r " ${GIT_REPO} " -f " ${COVERAGE_FILE } "
134127}
135128
136129# We use globs, make sure they are supported.
@@ -151,43 +144,35 @@ cd $(bazel info workspace)
151144bazel coverage --remote_download_outputs=all //src/...
152145
153146# Fixup paths for the UI coverage output
154- sed -i " s|SF:src|SF:src/ui/src|g" ${UI_OUTPUT}
147+ sed -i " s|SF:src|SF:src/ui/src|g" bazel-testlogs/src/ui/ui-tests/coverage.dat
155148
156149# This finds all the valid coverage files and then creates a list of them
157150# prefixed by -a, which allows up to add them to the lcov output.
158- # This part only works for C++ coverage.
159- file_merge_args=" "
160- for file in bazel-out/** /coverage.dat
161- do
162- # Only consider valid files. Some files only contain Go coverage and that
163- # does not work with LCOV.
164- lcov --summary " ${file} " > /dev/null 2>&1 && file_merge_args+=" -a ${file} "
151+ file_merge_args=()
152+ for file in bazel-out/** /coverage.dat; do
153+ # Only consider valid files.
154+ if [ -s " ${file} " ]; then
155+ file_merge_args+=(" -a" " ${file} " )
156+ fi
165157done
166158
167159# Merge all the files.
168- lcov $ file_merge_args -o cc_coverage.info
160+ lcov " ${ file_merge_args[@]} " -o ${COVERAGE_FILE}
169161
170162# Print out the summary.
171- lcov --summary ${CC_COVERAGE_FILE }
163+ lcov --summary ${COVERAGE_FILE }
172164
173165# Remove test files from the coverage files.
174- lcov -r ${CC_COVERAGE_FILE} ' **/*_test.cc' -o ${CC_COVERAGE_FILE}
175- lcov -r ${CC_COVERAGE_FILE} ' **/*_mock.cc' -o ${CC_COVERAGE_FILE}
176- lcov -r ${CC_COVERAGE_FILE} ' **/*_mock.h' -o ${CC_COVERAGE_FILE}
166+ lcov -r ${COVERAGE_FILE} ' **/*_test.cc' -o ${COVERAGE_FILE}
167+ lcov -r ${COVERAGE_FILE} ' **/*_mock.cc' -o ${COVERAGE_FILE}
168+ lcov -r ${COVERAGE_FILE} ' **/*_mock.h' -o ${COVERAGE_FILE}
169+ lcov -r ${COVERAGE_FILE} ' **/*_test.go' -o ${COVERAGE_FILE}
170+ lcov -r ${COVERAGE_FILE} ' **/*.gen.go' -o ${COVERAGE_FILE}
171+ lcov -r ${COVERAGE_FILE} ' **/*-mock.tsx' -o ${COVERAGE_FILE}
172+ lcov -r ${COVERAGE_FILE} ' **/*-mock.ts' -o ${COVERAGE_FILE}
177173
178174# Print out the final summary.
179- lcov --summary ${CC_COVERAGE_FILE}
180-
181- # Create go coverage file, by grabbing all the .go entries.
182- echo " mode: set" > coverage.tmp
183- for file in bazel-out/** /coverage.dat
184- do
185- grep " .go" ${file} >> coverage.tmp || true
186- done
187-
188- # Remove test files from the go coverage.
189- grep -v " _test.go" coverage.tmp > ${GO_COVERAGE_FILE}
190- rm -f coverage.tmp
175+ lcov --summary ${COVERAGE_FILE}
191176
192177# Upload to codecov.io.
193178if [ " ${UPLOAD_TO_CODECOV} " = true ]; then
0 commit comments