File: coverage.sh

package info (click to toggle)
golang-debian-vasudev-gospake2 0.2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 248 kB
  • sloc: makefile: 19; sh: 15
file content (24 lines) | stat: -rw-r--r-- 657 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

set -eu

COVERAGE_DIR="${COVERAGE_DIR:-coverage}"
PKG_LIST=$(go list ./... | grep -v /cmd/ | grep -v /groups/)


[ -d "$COVERAGE_DIR" ] || mkdir -p "$COVERAGE_DIR"

for package in ${PKG_LIST}; do
    go test -covermode=count -coverprofile "${COVERAGE_DIR}/${package##*/}.cov" "$package" ;
done ;


# Merge the coverage profile files
echo 'mode: count' > "${COVERAGE_DIR}"/coverage.cov ;
tail -q -n +2 "${COVERAGE_DIR}"/*.cov >> "${COVERAGE_DIR}"/coverage.cov ;

# Display the global code coverage
go tool cover -func="${COVERAGE_DIR}"/coverage.cov ;
go tool cover -html="${COVERAGE_DIR}"/coverage.cov -o coverage.html ;

rm -rf "${COVERAGE_DIR}"