diff --git a/.gitignore b/.gitignore index 64450fbb40..9c17d8bf34 100644 --- a/.gitignore +++ b/.gitignore @@ -76,15 +76,15 @@ gtags.conf # Delve generated file **/__debug_bin -# go-codecov +# codecov-go generated files coverage.txt profile.out -cover.out -coverage.html +profile.txt +go_coverage.html -#cpp-codecov -*.info -lcov_out/ +# codecov-cpp generated files +lcov_*.info +cpp_coverage/ # virtualenv venv/ diff --git a/Makefile b/Makefile index 505c2dfb59..e7596b6e53 100644 --- a/Makefile +++ b/Makefile @@ -121,15 +121,15 @@ test-cpp: build-cpp-with-unittest @(env bash $(PWD)/scripts/run_cpp_unittest.sh) # Runs code coverage. -codecov: go-codecov cpp-codecov +codecov: codecov-go codecov-cpp -# Run go-codecov -go-codecov: build-cpp-with-unittest +# Run codecov-go +codecov-go: build-cpp-with-unittest @echo "Running go coverage..." @(env bash $(PWD)/scripts/run_go_codecov.sh) -# Run cpp-codecov -cpp-codecov: build-cpp-with-unittest +# Run codecov-cpp +codecov-cpp: build-cpp-with-unittest @echo "Running cpp coverage..." @(env bash $(PWD)/scripts/run_cpp_codecov.sh) diff --git a/scripts/run_cpp_codecov.sh b/scripts/run_cpp_codecov.sh index 65119e8cd9..e1054eebba 100755 --- a/scripts/run_cpp_codecov.sh +++ b/scripts/run_cpp_codecov.sh @@ -24,7 +24,7 @@ FILE_INFO_BASE="${ROOT_DIR}/lcov_base.info" FILE_INFO_UT="${ROOT_DIR}/lcov_ut.info" FILE_INFO_COMBINE="${ROOT_DIR}/lcov_combine.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/" # delete old code coverage info files diff --git a/scripts/run_go_codecov.sh b/scripts/run_go_codecov.sh index 9110b10147..21efb12821 100755 --- a/scripts/run_go_codecov.sh +++ b/scripts/run_go_codecov.sh @@ -1,12 +1,14 @@ #!/usr/bin/env bash set -e -echo "" > coverage.txt +echo "mode: atomic" > coverage.txt for d in $(go list ./internal... | grep -v vendor); do go test -race -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d" if [ -f profile.out ]; then - cat profile.out >> coverage.txt + sed '1d' profile.out >> coverage.txt rm profile.out fi done + +go tool cover -html=./coverage.txt -o ./go_coverage.html