1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-04-25 13:48:49 +08:00
golearn/coverage.sh
2018-06-16 23:16:22 +08:00

24 lines
456 B
Bash
Executable File

#!/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