1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-04-25 13:48:49 +08:00

Update .travis.yml and coverage script

This commit is contained in:
ss8651twtw 2018-06-16 23:11:33 +08:00
parent 6af3dea823
commit 2a48e1f1b9
2 changed files with 24 additions and 1 deletions

View File

@ -16,7 +16,7 @@ install:
- go get -v ./...
script:
- go test -v -coverprofile=coverage.txt -covermode=atomic ./...
- ./coverage.sh
after_success:
- bash <(curl -s https://codecov.io/bash)

23
coverage.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
set -e
workdir=.cover
profile=${workdir}/cover.out
mode=count
generate_cover_data() {
rm -rf ${workdir}
mkdir ${workdir}
for pkg in "$@"; do
f="${workdir}/$(echo ${pkg} | tr / -).cover"
go test -covermode=${mode} -coverprofile=${f} ${pkg}
done
echo "mode: ${mode} > ${profile}"
grep -h -v "^mode:" "${workdir}"/*.cover >>"${profile}"
}
generate_cover_data $(go list ./...)
mv ${profile} coverage.txt