Browse Source

Merge pull request #7661 from heyitsanthony/cov-fail-report

test: generate coverage report even if some tests fail
Anthony Romano 8 years ago
parent
commit
c0fc389c98
1 changed files with 15 additions and 5 deletions
  1. 15 5
      test

+ 15 - 5
test

@@ -109,25 +109,35 @@ function cov_pass {
 	mkdir -p "$COVERDIR"
 
 	# run code coverage for unit and integration tests
+	GOCOVFLAGS="-covermode=set -coverpkg $PKGS_COMMA -v -timeout 15m"
+	failed=""
 	for t in `echo "${TEST_PKGS}" | egrep -v "(e2e|functional-tester)"`; do
 		tf=`echo $t | tr / _`
 		# cache package compilation data for faster repeated builds
-		go test -covermode=set -coverpkg $PKGS_COMMA -i -v ${REPO_PATH}/$t
+		go test $GOCOVFLAGS -i ${REPO_PATH}/$t || true
 		# uses -run=Test to skip examples because clientv3/ example tests will leak goroutines
-		go test -covermode=set -coverpkg $PKGS_COMMA -timeout 15m -run=Test -v -coverprofile "$COVERDIR/${tf}.coverprofile"  ${REPO_PATH}/$t
+		go test $GOCOVFLAGS -run=Test -coverprofile "$COVERDIR/${tf}.coverprofile"  ${REPO_PATH}/$t || failed="$failed $t"
 	done
 
 	# proxy tests
-	go test -tags cluster_proxy -covermode=set -coverpkg $PKGS_COMMA -timeout 15m -v -coverprofile "$COVERDIR/proxy_integration.coverprofile" ${REPO_PATH}/integration
-	go test -tags cluster_proxy -covermode=set -coverpkg $PKGS_COMMA -timeout 15m -v -coverprofile "$COVERDIR/proxy_clientv3.coverprofile" ${REPO_PATH}/clientv3/integration
+	go test -tags cluster_proxy $GOCOVFLAGS -coverprofile "$COVERDIR/proxy_integration.coverprofile" ${REPO_PATH}/integration || failed="$failed proxy-integration"
+	go test -tags cluster_proxy $GOCOVFLAGS -coverprofile "$COVERDIR/proxy_clientv3.coverprofile" ${REPO_PATH}/clientv3/integration || failed="$failed proxy-clientv3/integration"
 
 	# run code coverage for e2e tests
 	# use 30m timeout because e2e coverage takes longer
 	# due to many tests cause etcd process to wait
 	# on leadership transfer timeout during gracefully shutdown
-	go test -tags cov -timeout 30m -v ${REPO_PATH}"/e2e"
+	go test -tags cov -timeout 30m -v ${REPO_PATH}"/e2e" || failed="$failed e2e"
 
 	gocovmerge "$COVERDIR"/*.coverprofile >"$COVERDIR"/cover.out
+
+	# held failures to generate the full coverage file, now fail
+	if [ -n "$failed" ]; then
+		for f in $failed; do
+			echo FAIL $f
+		done
+		exit 255
+	fi
 }
 
 function e2e_pass {