mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
scripts/coverage.sh: detect use of "-mod vendor"
This commit is contained in:
@@ -30,8 +30,14 @@ function push_to_codecov() {
|
|||||||
covermode=${COVERMODE:-atomic}
|
covermode=${COVERMODE:-atomic}
|
||||||
coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX)
|
coverdir=$(mktemp -d /tmp/coverage.XXXXXXXXXX)
|
||||||
profile="${coverdir}/profile.out"
|
profile="${coverdir}/profile.out"
|
||||||
|
|
||||||
|
cwd="$PWD"
|
||||||
|
if [ -s "$cwd/go.mod" -a -d "$cwd/vendor" ]; then
|
||||||
|
mod_args=(-mod vendor)
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$pkgs" ]; then
|
if [ -z "$pkgs" ]; then
|
||||||
pkgs="$(go list -mod vendor -test ./... | grep '\.test$' | sed -e 's/\.test$//')"
|
pkgs="$(go list "${mod_args[@]}" -test ./... | grep '\.test$' | sed -e 's/\.test$//')"
|
||||||
pkgs="$(echo "$pkgs" | grep -vE 'host-image|hostimage')"
|
pkgs="$(echo "$pkgs" | grep -vE 'host-image|hostimage')"
|
||||||
fi
|
fi
|
||||||
if type circleci &>/dev/null; then
|
if type circleci &>/dev/null; then
|
||||||
@@ -44,7 +50,7 @@ echo "$pkgs" | xargs -n 8 --no-run-if-empty echo \
|
|||||||
go test -v \
|
go test -v \
|
||||||
-coverprofile="$profile.tmp" \
|
-coverprofile="$profile.tmp" \
|
||||||
-covermode="$covermode" \
|
-covermode="$covermode" \
|
||||||
-mod vendor \
|
"${mod_args[@]}" \
|
||||||
-ldflags '-w' \
|
-ldflags '-w' \
|
||||||
$batch; \
|
$batch; \
|
||||||
tail -n +2 "$profile.tmp" >>"$profile"; \
|
tail -n +2 "$profile.tmp" >>"$profile"; \
|
||||||
|
|||||||
Reference in New Issue
Block a user