2016-07-29 11:37:37 +02:00
|
|
|
#!/bin/bash
|
2016-08-16 07:45:59 +02:00
|
|
|
set -e
|
2016-07-29 11:37:37 +02:00
|
|
|
echo "mode: set" >>profile.cov
|
2016-08-31 10:26:44 +02:00
|
|
|
|
|
|
|
deps=""
|
|
|
|
|
|
|
|
# listDeps lists packages referenced by package in $1,
|
|
|
|
# excluding golang standard library and packages in
|
|
|
|
# direcotry vendor
|
|
|
|
function listDeps(){
|
|
|
|
pkg=$1
|
|
|
|
deps=$pkg
|
|
|
|
ds=$(echo $(go list -f '{{.Imports}}' $pkg) | sed 's/[][]//g')
|
|
|
|
for d in $ds
|
|
|
|
do
|
|
|
|
if echo $d | grep -q "github.com/vmware/harbor" && echo $d | grep -qv "vendor"
|
|
|
|
then
|
|
|
|
deps="$deps,$d"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
packages=$(go list ./... | grep -v -E 'vendor|tests')
|
|
|
|
|
|
|
|
for package in $packages
|
2016-07-29 11:37:37 +02:00
|
|
|
do
|
2016-08-31 10:26:44 +02:00
|
|
|
listDeps $package
|
2017-10-01 23:03:53 +02:00
|
|
|
|
2018-02-27 08:01:14 +01:00
|
|
|
# echo "DEBUG: testing package $package"
|
2017-12-19 09:25:07 +01:00
|
|
|
go test -race -cover -coverprofile=profile.tmp -coverpkg "$deps" $package
|
2016-08-31 10:26:44 +02:00
|
|
|
if [ -f profile.tmp ]
|
|
|
|
then
|
|
|
|
cat profile.tmp | tail -n +2 >> profile.cov
|
|
|
|
rm profile.tmp
|
|
|
|
fi
|
2016-07-29 11:37:37 +02:00
|
|
|
done
|