summaryrefslogtreecommitdiff
path: root/hack/lib/golang.sh
diff options
context:
space:
mode:
authorXiang Dai <long0dai@foxmail.com>2020-09-11 16:07:09 +0800
committerXiang Dai <long0dai@foxmail.com>2021-01-09 09:36:10 +0800
commit41453952e6be69e02b4863617c49d2d566e9c104 (patch)
tree814063873d41aed9d96d082286d174fd1083704c /hack/lib/golang.sh
parentMerge pull request #2437 from Abirdcfly/master (diff)
downloadkubeedge-41453952e6be69e02b4863617c49d2d566e9c104.tar.gz
Generate coverprofile when test
Signed-off-by: Xiang Dai <long0dai@foxmail.com>
Diffstat (limited to 'hack/lib/golang.sh')
-rwxr-xr-xhack/lib/golang.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/hack/lib/golang.sh b/hack/lib/golang.sh
index 9bba8e1e3..3685166dd 100755
--- a/hack/lib/golang.sh
+++ b/hack/lib/golang.sh
@@ -434,5 +434,11 @@ kubeedge::golang::run_test() {
testdirs+=("${KUBEEDGE_ALL_TESTCASES[@]}")
fi
- go test ${testdirs[@]}
+ local profile=${PROFILE:-""}
+ if [[ $profile ]]; then
+ go test "-coverprofile=${profile}" ${testdirs[@]}
+ go tool cover -func=coverage.out
+ else
+ go test ${testdirs[@]}
+ fi
}