From fd441fcddbe5c9eadfc0b8ad2df4a59d9b03f4dd Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Sun, 15 Nov 2020 18:35:05 +0300 Subject: [PATCH] ci: fix coverage --- .gitignore | 3 +++ Makefile | 4 +++- go.coverage.sh | 12 ++++++++++++ go.test.sh | 9 +++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 go.coverage.sh create mode 100755 go.test.sh diff --git a/.gitignore b/.gitignore index 69536b2..337922c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ _fuzz/*/crashers _fuzz/*/suppressions .idea + +# coverage and other outputs +*.out diff --git a/Makefile b/Makefile index 6c1565f..5a9bb4c 100644 --- a/Makefile +++ b/Makefile @@ -22,4 +22,6 @@ fuzz-schema-coordinator: go-fuzz -coordinator localhost:1105 -workdir _fuzz/schema/ test: - go test ./... + @./go.test.sh +coverage: + @./go.coverage.sh diff --git a/go.coverage.sh b/go.coverage.sh new file mode 100755 index 0000000..a0049d8 --- /dev/null +++ b/go.coverage.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e +touch coverage.out + +for d in $(go list ./... | grep -v vendor); do + go test -coverprofile=profile.out -covermode=atomic "$d" + if [[ -f profile.out ]]; then + cat profile.out >> coverage.out + rm profile.out + fi +done diff --git a/go.test.sh b/go.test.sh new file mode 100755 index 0000000..0818fe7 --- /dev/null +++ b/go.test.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set -e + +# test fuzz inputs +go test -tags gofuzz -run TestFuzz -v . + +# test with -race +go test -race ./...