github.com/status-im/status-go@v1.1.0/_assets/scripts/test-with-coverage.sh (about) 1 #!/usr/bin/env bash 2 set -eu 3 4 packages="" 5 coverage_file_path="$(mktemp coverage.out.rerun.XXXXXXXXXX --tmpdir="${TEST_WITH_COVERAGE_REPORTS_DIR}")" 6 count=1 7 8 # This is a hack to workaround gotestsum behaviour. When using a --raw-command, 9 # gotestsum will only pass the package when rerunning a test. Otherwise we should pass the package ourselves. 10 # https://github.com/gotestyourself/gotestsum/blob/03568ab6d48faabdb632013632ac42687b5f17d1/cmd/main.go#L331-L336 11 if [[ "$*" != *"-test.run"* ]]; then 12 packages="${TEST_WITH_COVERAGE_PACKAGES}" 13 count=${TEST_WITH_COVERAGE_COUNT} 14 fi 15 16 go test -json \ 17 ${packages} \ 18 -count=${count} \ 19 -covermode=atomic \ 20 -coverprofile="${coverage_file_path}" \ 21 -coverpkg ./... \ 22 "$@"