Update code coverage script (#8280)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
This commit is contained in:
groot 2021-09-22 16:01:53 +08:00 committed by GitHub
parent f834ceafdd
commit 77e88144fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 14 deletions

12
.gitignore vendored
View File

@ -76,15 +76,15 @@ gtags.conf
# Delve generated file # Delve generated file
**/__debug_bin **/__debug_bin
# go-codecov # codecov-go generated files
coverage.txt coverage.txt
profile.out profile.out
cover.out profile.txt
coverage.html go_coverage.html
#cpp-codecov # codecov-cpp generated files
*.info lcov_*.info
lcov_out/ cpp_coverage/
# virtualenv # virtualenv
venv/ venv/

View File

@ -121,15 +121,15 @@ test-cpp: build-cpp-with-unittest
@(env bash $(PWD)/scripts/run_cpp_unittest.sh) @(env bash $(PWD)/scripts/run_cpp_unittest.sh)
# Runs code coverage. # Runs code coverage.
codecov: go-codecov cpp-codecov codecov: codecov-go codecov-cpp
# Run go-codecov # Run codecov-go
go-codecov: build-cpp-with-unittest codecov-go: build-cpp-with-unittest
@echo "Running go coverage..." @echo "Running go coverage..."
@(env bash $(PWD)/scripts/run_go_codecov.sh) @(env bash $(PWD)/scripts/run_go_codecov.sh)
# Run cpp-codecov # Run codecov-cpp
cpp-codecov: build-cpp-with-unittest codecov-cpp: build-cpp-with-unittest
@echo "Running cpp coverage..." @echo "Running cpp coverage..."
@(env bash $(PWD)/scripts/run_cpp_codecov.sh) @(env bash $(PWD)/scripts/run_cpp_codecov.sh)

View File

@ -24,7 +24,7 @@ FILE_INFO_BASE="${ROOT_DIR}/lcov_base.info"
FILE_INFO_UT="${ROOT_DIR}/lcov_ut.info" FILE_INFO_UT="${ROOT_DIR}/lcov_ut.info"
FILE_INFO_COMBINE="${ROOT_DIR}/lcov_combine.info" FILE_INFO_COMBINE="${ROOT_DIR}/lcov_combine.info"
FILE_INFO_OUTPUT="${ROOT_DIR}/lcov_output.info" FILE_INFO_OUTPUT="${ROOT_DIR}/lcov_output.info"
DIR_LCOV_OUTPUT="${ROOT_DIR}/lcov_html" DIR_LCOV_OUTPUT="${ROOT_DIR}/cpp_coverage"
DIR_GCNO="${ROOT_DIR}/cmake_build/" DIR_GCNO="${ROOT_DIR}/cmake_build/"
# delete old code coverage info files # delete old code coverage info files

View File

@ -1,12 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -e
echo "" > coverage.txt echo "mode: atomic" > coverage.txt
for d in $(go list ./internal... | grep -v vendor); do for d in $(go list ./internal... | grep -v vendor); do
go test -race -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d" go test -race -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d"
if [ -f profile.out ]; then if [ -f profile.out ]; then
cat profile.out >> coverage.txt sed '1d' profile.out >> coverage.txt
rm profile.out rm profile.out
fi fi
done done
go tool cover -html=./coverage.txt -o ./go_coverage.html