From 00e581754bc580e80d5f3cbfc068ad7a36cca102 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Wed, 31 May 2017 13:50:09 -0700 Subject: [PATCH] test: incrementally merge coverage files Don't throw away all coverage data if some profiles are corrupted. --- test | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test b/test index a1d95c09d..6cc114d00 100755 --- a/test +++ b/test @@ -129,7 +129,16 @@ function cov_pass { # on leadership transfer timeout during gracefully shutdown go test -tags cov -timeout 30m -v ${REPO_PATH}"/e2e" || failed="$failed e2e" - gocovmerge "$COVERDIR"/*.coverprofile >"$COVERDIR"/cover.out + # incrementally merge to get coverage data even if some coverage files are corrupted + # optimistically assume etcdserver package's coverage file is OK since gocovmerge + # expects to start with a non-empty file + cp "$COVERDIR"/etcdserver.coverprofile "$COVERDIR"/cover.out + for f in "$COVERDIR"/*.coverprofile; do + gocovmerge $f "$COVERDIR"/cover.out >"$COVERDIR"/cover.tmp || failed="$failed $f" + if [ -s "$COVERDIR"/cover.tmp ]; then + mv "$COVERDIR"/cover.tmp "$COVERDIR"/cover.out + fi + done # strip out generated files (using GNU-style sed) sed --in-place '/generated.go/d' "$COVERDIR"/cover.out || true