From 3d9ecfb7793bf666abc484a8f6ef32bb76ee3a35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 5 Mar 2020 23:17:03 +0000 Subject: [PATCH] fix(tests): fix exit code for failed tests --- scripts/gocover.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/gocover.sh b/scripts/gocover.sh index 0c4a65e93..35bc62948 100755 --- a/scripts/gocover.sh +++ b/scripts/gocover.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash -set -e +set -o errexit +set -o pipefail trap cleanup INT @@ -11,11 +12,12 @@ function cleanup() { echo "" > coverage.txt -for d in $(go list ./... | grep -vE 'prymitive/karma/internal/mapper/v017/(client|models)'); do - go test \ - -coverprofile=profile.out \ - -coverpkg=$(go list ./... | grep -vE 'prymitive/karma/internal/mapper/v017/(client|models)' | tr '\n' ',') \ - $d 2>&1 | grep -v 'warning: no packages being tested depend on matches for pattern' | sed s/'of statements in .*'/''/g +PKGS=$(go list ./... | grep -vE 'prymitive/karma/internal/mapper/v017/(client|models)') +COVERPKG=$(echo "$PKGS" | tr '\n' ',') +for d in $PKGS; do + (go test -coverprofile=profile.out -coverpkg="$COVERPKG" $d 2>&1 || exit 2) \ + | grep -v 'warning: no packages being tested depend on matches for pattern' \ + | sed s/'of statements in .*'/''/g if [ -f profile.out ]; then cat profile.out >> coverage.txt rm profile.out