| 1 |
#!/bin/bash -e |
| 2 |
# Run from the repo root: ./scripts/cov.sh [CI] |
| 3 |
|
| 4 |
rm -rf ./cov |
| 5 |
mkdir cov |
| 6 |
|
| 7 |
# White-box tests at the repo root (skip_no_race_tests excludes the NoRace |
| 8 |
# norace_test.go that lives in ./test and we cover separately below). |
| 9 |
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/nats.out . -tags=skip_no_race_tests |
| 10 |
|
| 11 |
# Integration tests against the core nats.go package. |
| 12 |
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/test.out -coverpkg=github.com/nats-io/nats.go ./test -tags=skip_no_race_tests,internal_testing |
| 13 |
|
| 14 |
# Integration tests against the new jetstream package. |
| 15 |
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/jetstream.out -coverpkg=github.com/nats-io/nats.go/jetstream -p=1 ./jetstream/... |
| 16 |
|
| 17 |
# Integration tests against the micro package. |
| 18 |
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/service.out -coverpkg=github.com/nats-io/nats.go/micro -p=1 ./micro/... |
| 19 |
|
| 20 |
# Encoders (only their dedicated tests in ./test). |
| 21 |
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/builtin.out -coverpkg=github.com/nats-io/nats.go/encoders/builtin ./test -run 'TestEncBuiltin|TestEncodedConn' -tags=skip_no_race_tests |
| 22 |
go test -modfile=go_test.mod --failfast -vet=off -v -covermode=atomic -coverprofile=./cov/protobuf.out -coverpkg=github.com/nats-io/nats.go/encoders/protobuf ./test -run 'TestEncProto' -tags=skip_no_race_tests |
| 23 |
|
| 24 |
gocovmerge ./cov/*.out > acc.out |
| 25 |
rm -rf ./cov |
| 26 |
|
| 27 |
# Without argument, launch browser results. We are going to push to coveralls only |
| 28 |
# from ci.yml and after success of the build (and result of pushing will not affect |
| 29 |
# build result). |
| 30 |
if [[ $1 == "" ]]; then |
| 31 |
go tool cover -html=acc.out |
| 32 |
fi |