From 746fc556a013fdf3581ff03354b88e187934a1fc Mon Sep 17 00:00:00 2001 From: Xiangyu Wang Date: Sat, 24 Apr 2021 15:10:24 +0800 Subject: [PATCH] [skip ci]Add go code coverage (#5024) Signed-off-by: Xiangyu Wang --- .gitignore | 4 ++++ Makefile | 5 +++++ scripts/run_go_codecov.sh | 12 ++++++++++++ 3 files changed, 21 insertions(+) create mode 100755 scripts/run_go_codecov.sh diff --git a/.gitignore b/.gitignore index 86b253e7eb..7c5d75d8ed 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,7 @@ gtags.conf # Delve generated file **/__debug_bin + +# go-codecov +coverage.txt +profile.out diff --git a/Makefile b/Makefile index 6f0f449b3a..d3df2405cb 100644 --- a/Makefile +++ b/Makefile @@ -154,6 +154,11 @@ test-cpp: build-cpp-with-unittest @echo "Running cpp unittests..." @(env bash $(PWD)/scripts/run_cpp_unittest.sh) +# Run go-codecov +go-codecov: + @echo "Running go unittests..." + @(env bash $(PWD)/scripts/run_go_codecov.sh) + #TODO: build each component to docker docker: verifiers diff --git a/scripts/run_go_codecov.sh b/scripts/run_go_codecov.sh new file mode 100755 index 0000000000..c9d5f25a44 --- /dev/null +++ b/scripts/run_go_codecov.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +echo "" > coverage.txt + +for d in $(go list ./internal... | grep -v vendor); do + go test -race -coverprofile=profile.out -covermode=atomic "$d" + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi +done