File: project-code-coverage.sh

package info (click to toggle)
golang-github-blevesearch-bleve 0.5.0%2Bgit20170912.278.6eea5b78-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,764 kB
  • sloc: yacc: 311; sh: 51; makefile: 7
file content (52 lines) | stat: -rwxr-xr-x 1,268 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

echo "mode: count" > acc.out
for Dir in . $(find ./* -maxdepth 10 -type d | grep -v vendor);
do
	if ls $Dir/*.go &> /dev/null;
	then
		returnval=`go test -coverprofile=profile.out -covermode=count $Dir`
		echo ${returnval}
		if [[ ${returnval} != *FAIL* ]]
		then
    		if [ -f profile.out ]
    		then
        		cat profile.out | grep -v "mode: count" >> acc.out
    		fi
    	else
    		exit 1
    	fi
    fi
done

# collect integration test coverage
echo "mode: count" > integration-acc.out
INTPACKS=`go list ./... | grep -v vendor | grep -v utils | grep -v 'store/test' | grep -v docs | xargs | sed 's/ /,/g'`
returnval=`go test -coverpkg=$INTPACKS -coverprofile=profile.out -covermode=count ./test`
if [[ ${returnval} != *FAIL* ]]
then
    if [ -f profile.out ]
    then
        cat profile.out | grep -v "mode: count" >> integration-acc.out
    fi
else
    exit 1
fi

cat acc.out integration-acc.out | go run docs/merge-coverprofile.go > merged.out

if [ -n "$COVERALLS" ]
then
    export GIT_BRANCH=$TRAVIS_BRANCH
	goveralls -service drone.io -coverprofile=merged.out -repotoken $COVERALLS
fi

if [ -n "$COVERHTML" ]
then
    go tool cover -html=merged.out
fi

rm -rf ./profile.out
rm -rf ./acc.out
rm -rf ./integration-acc.out
rm -rf ./merged.out