mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Fix code coverage measurement.
This commit is contained in:
17
test.sh
17
test.sh
@@ -197,9 +197,8 @@ function grpcproxy_pass {
|
||||
|
||||
# Builds artifacts used by tests/e2e in coverage mode.
|
||||
function build_cov_pass {
|
||||
local out="${BINDIR:-./bin}"
|
||||
run go test -tags cov -c -covermode=set -coverpkg="./..." -o "${out}/etcd_test"
|
||||
run go test -tags cov -c -covermode=set -coverpkg="./..." -o "${out}/etcdctl_test" "./etcdctl"
|
||||
run_for_module "server" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcd_test"
|
||||
run_for_module "etcdctl" run go test -tags cov -c -covermode=set -coverpkg="./..." -o "../bin/etcdctl_test"
|
||||
}
|
||||
|
||||
# pkg_to_coverflag [prefix] [pkgs]
|
||||
@@ -212,6 +211,10 @@ function pkg_to_coverprofileflag {
|
||||
echo -n "-coverprofile=${coverdir}/${prefix}_${pkgs_normalized}.coverprofile"
|
||||
}
|
||||
|
||||
function not_test_packages {
|
||||
run_for_modules pkgs_in_module "./..." | grep -v /etcd/tests/v3/
|
||||
}
|
||||
|
||||
function cov_pass {
|
||||
# shellcheck disable=SC2153
|
||||
if [ -z "$COVERDIR" ]; then
|
||||
@@ -230,7 +233,7 @@ function cov_pass {
|
||||
rm -f "${coverdir}/*.coverprofile" "${coverdir}/cover.*"
|
||||
|
||||
local covpkgs
|
||||
covpkgs=$(pkgs_in_module "./...")
|
||||
covpkgs=$(not_test_packages)
|
||||
local coverpkg_comma
|
||||
coverpkg_comma=$(echo "${covpkgs[@]}" | xargs | tr ' ' ',')
|
||||
local gocov_build_flags=("-covermode=set" "-coverpkg=$coverpkg_comma")
|
||||
@@ -238,8 +241,10 @@ function cov_pass {
|
||||
local failed=""
|
||||
|
||||
log_callout "Collecting coverage from unit tests ..."
|
||||
go_test "./..." "keep_going" "pkg_to_coverprofileflag unit" -short -timeout=30m \
|
||||
"${gocov_build_flags[@]}" "$@" || failed="$failed unit"
|
||||
for m in $(module_dirs); do
|
||||
run_for_module "${m}" go_test "./..." "keep_going" "pkg_to_coverprofileflag unit" -short -timeout=30m \
|
||||
"${gocov_build_flags[@]}" "$@" || failed="$failed unit"
|
||||
done
|
||||
|
||||
log_callout "Collecting coverage from integration tests ..."
|
||||
run_for_module "tests" go_test "./integration/..." "keep_going" "pkg_to_coverprofileflag integration" \
|
||||
|
||||
Reference in New Issue
Block a user