diff --git a/go/.gitignore b/go/.gitignore new file mode 100644 index 00000000..404abb22 --- /dev/null +++ b/go/.gitignore @@ -0,0 +1 @@ +coverage/ diff --git a/go/README.md b/go/README.md index 7b017964..c226e19f 100644 --- a/go/README.md +++ b/go/README.md @@ -15,7 +15,5 @@ go test ./... - Run tests and coverage : ```shell -go test ./... -coverprofile=coverage.out - -go tool cover -html=coverage.out +./test-with-coverage.sh ``` \ No newline at end of file diff --git a/go/test-with-coverage.sh b/go/test-with-coverage.sh new file mode 100755 index 00000000..4430cb8d --- /dev/null +++ b/go/test-with-coverage.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -e +[ -d coverage ] || mkdir coverage +go test ./... -coverprofile=coverage/coverage.out +go tool cover -html=coverage/coverage.out -o coverage/index.html +echo "Starting web server to present the coverage report. Visit at http://localhost:8000. Press 'Ctrl' + 'C' to exit." +python -m http.server 8000 --bind 127.0.0.1 --directory coverage 2>&1 | grep -v "GET /.* 200 -"