gitlab 单元测试覆盖率之2

GO项目跑整个项目的覆盖率

gitlab-ci.sh 内容如下

set -e echo “mode: atomic” > coverage.txt

for d in $(go list ./… | grep -v vendor | grep -v doc); do
go test -race -coverprofile=profile.out $d
if [ -f profile.out ]; then
cat profile.out | grep -v statements | grep -v atomic >> coverage.txt
rm profile.out
fi done

go tool cover -func=coverage.txt

发表评论

电子邮件地址不会被公开。 必填项已用*标注