File: coverage.sh

package info (click to toggle)
dnss 0.0~git20180721.0.2de63ab0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 232 kB
  • sloc: sh: 246; makefile: 5
file content (35 lines) | stat: -rwxr-xr-x 867 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#
# Run tests in coverage mode, generating HTML and function reports.
#

set -e

# The tests are run from the repository root.
cd "$(realpath `dirname ${0}`)/../"

# Recreate the coverage output directory, to avoid including stale results
# from previous runs.
rm -rf .coverage
mkdir -p .coverage
export COVER_DIR="$PWD/.coverage"


go test \
	-covermode=count \
	-coverprofile="$COVER_DIR/pkg-tests.out" \
	-coverpkg=./... \
	./...

# These will run in coverage mode due to $COVER_DIR being set.
setsid -w ./tests/external.sh

# Merge all coverage output into a single file.
go run "tests/gocovcat.go" .coverage/*.out \
        > .coverage/all.out

go tool cover -func=.coverage/all.out | sort -k 3 -n > ".func.txt"
go tool cover -html=.coverage/all.out -o .coverage/dnss.cover.html

grep -i total .func.txt
echo "file:///$PWD/.coverage/dnss.cover.html"