mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-29 21:54:13 +01:00
Merge pull request #822 from ywk253100/test
Calculate coverage for all packages referenced by the package
This commit is contained in:
commit
9bbdbfa520
@ -1,12 +1,35 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
echo "mode: set" >>profile.cov
|
echo "mode: set" >>profile.cov
|
||||||
for dir in $(go list ./... | grep -v -E 'vendor|tests')
|
|
||||||
|
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
|
||||||
do
|
do
|
||||||
go test -cover -coverprofile=profile.tmp $dir
|
listDeps $package
|
||||||
if [ -f profile.tmp ]
|
|
||||||
then
|
go test -cover -coverprofile=profile.tmp -coverpkg "$deps" $package
|
||||||
cat profile.tmp | tail -n +2 >> profile.cov
|
if [ -f profile.tmp ]
|
||||||
rm profile.tmp
|
then
|
||||||
fi
|
cat profile.tmp | tail -n +2 >> profile.cov
|
||||||
|
rm profile.tmp
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user