3
tmp_directory="$(mktemp -d)"
4
coverage_final=$tmp_directory/coverage.out
5
coverage_scope=$tmp_directory/coverage_scope.out
6
coverage_webdm=$tmp_directory/coverage_webdm.out
3
coverage_final="$(mktemp)"
5
# get_coverage runs the given tests and adds the results to the final coverage
9
# $1: Go path under test.
10
# $2: Final coverage report.
14
local coverage_final=$2
15
local coverage_tmp="$(mktemp)"
17
go test $go_path -coverprofile=$coverage_tmp
19
if [ $returnValue -eq 0 ]; then
20
# Tests passed, so add this to the final coverage file
21
cat $coverage_tmp | grep -v "mode: set" >> $coverage_final
23
exit $returnValue # Tests failed, so this script should also fail
8
27
# Setup final coverage file
9
28
echo "mode: set" > $coverage_final
11
# Add the scope's coverage to the overarching coverage file
12
go test launchpad.net/unity-scope-snappy/scope -coverprofile=$coverage_scope
13
cat $coverage_scope | grep -v "mode: set" >> $coverage_final
30
# Add the scope's coverage to the final coverage file
31
get_coverage "launchpad.net/unity-scope-snappy/scope" $coverage_final
15
# Add webdm's coverage to the overarching coverage file
16
go test launchpad.net/unity-scope-snappy/webdm -coverprofile=$coverage_webdm
17
cat $coverage_webdm | grep -v "mode: set" >> $coverage_final
33
# Add webdm's coverage to the final coverage file
34
get_coverage "launchpad.net/unity-scope-snappy/webdm" $coverage_final
19
36
if [ "$1" == "xml" ]; then
20
37
gocov convert $coverage_final | gocov-xml > coverage.xml