2016-07-29 11:37:37 +02:00
|
|
|
#!/bin/bash
|
2023-11-05 07:37:25 +01:00
|
|
|
set -x
|
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=""
|
2023-11-05 07:37:25 +01:00
|
|
|
cd $(dirname $(find . -name go.mod))
|
|
|
|
set +x
|
2016-08-31 10:26:44 +02:00
|
|
|
# listDeps lists packages referenced by package in $1,
|
2023-11-05 07:37:25 +01:00
|
|
|
# excluding golang standard library
|
2016-08-31 10:26:44 +02:00
|
|
|
function listDeps(){
|
|
|
|
pkg=$1
|
|
|
|
deps=$pkg
|
|
|
|
ds=$(echo $(go list -f '{{.Imports}}' $pkg) | sed 's/[][]//g')
|
|
|
|
for d in $ds
|
|
|
|
do
|
2023-11-05 07:37:25 +01:00
|
|
|
if echo $d | grep -q "github.com/goharbor/harbor" && echo $d
|
2016-08-31 10:26:44 +02:00
|
|
|
then
|
|
|
|
deps="$deps,$d"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-11-05 07:37:25 +01:00
|
|
|
packages=$(go list ./... | grep -v -E 'tests|testing')
|
2019-12-11 12:11:20 +01:00
|
|
|
echo testing packages: $packages
|
2016-08-31 10:26:44 +02:00
|
|
|
|
|
|
|
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"
|
2019-12-11 12:11:20 +01:00
|
|
|
echo go test -race -v -cover -coverprofile=profile.tmp -coverpkg "$deps" $package
|
|
|
|
go test -race -v -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
|