diff options
| author | CrazyMax <crazy-max@users.noreply.github.com> | 2022-08-26 20:19:00 +0200 |
|---|---|---|
| committer | CrazyMax <crazy-max@users.noreply.github.com> | 2022-09-08 12:12:03 +0200 |
| commit | 807c849431d1ccb15e5d010c19ee5dfaa8b11eb7 (patch) | |
| tree | 146886ac3fda6690db6f826f485193fd5bd6c25a /hack/make | |
| parent | 4c8af0e2f9d4e975ad98c77c8556cd23687a8a8d (diff) | |
| download | docker-807c849431d1ccb15e5d010c19ee5dfaa8b11eb7.tar.gz | |
ci(test): send coverage to codecov
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
Diffstat (limited to 'hack/make')
| -rw-r--r-- | hack/make/.integration-test-helpers | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/hack/make/.integration-test-helpers b/hack/make/.integration-test-helpers index 87614fea03..bbfc4edb86 100644 --- a/hack/make/.integration-test-helpers +++ b/hack/make/.integration-test-helpers @@ -16,6 +16,7 @@ source "${MAKEDIR}/.go-autogen" : "${TEST_REPEAT:=1}" : "${TESTFLAGS:=}" : "${TESTDEBUG:=}" +: "${TESTCOVERAGE:=}" : "${GOCACHE:=$(go env GOCACHE)}" setup_integration_test_filter() { @@ -80,7 +81,13 @@ run_test_integration_suites() { # Finally, we use periods as separator (instead of slashes) to be more # in line with Java package names (which is what junit.xml was designed for) pkgname="$(go env GOARCH).${pkgname//\//.}" - echo "Running $PWD (${pkgname}) flags=${flags}" + + pkgtestflags=$flags + if [ -n "${TESTCOVERAGE}" ]; then + pkgtestflags="$pkgtestflags -test.coverprofile=${ABS_DEST}/${pkgname//./-}-coverage.out" + fi + + echo "Running $PWD (${pkgname}) flags=${pkgtestflags}" [ -n "$TESTDEBUG" ] && set -x # shellcheck disable=SC2086 test_env gotestsum \ @@ -88,7 +95,7 @@ run_test_integration_suites() { --jsonfile="${ABS_DEST}/${pkgname//./-}-go-test-report.json" \ --junitfile="${ABS_DEST}/${pkgname//./-}-junit-report.xml" \ --raw-command \ - -- go tool test2json -p "${pkgname}" -t ./test.main ${flags} + -- go tool test2json -p "${pkgname}" -t ./test.main ${pkgtestflags} ); then exit 1; fi done } @@ -112,8 +119,12 @@ build_test_suite_binaries() { build_test_suite_binary() { local dir="$1" local out="$2" + local testflags echo Building test suite binary "$dir/$out" - go test -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "$dir" + if [ -n "${TESTCOVERAGE}" ]; then + testflags="-cover -covermode=atomic" + fi + go test ${testflags} -c -o "$dir/$out" -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" "$dir" } cleanup_test_suite_binaries() { |
