Adjusted instruction/procedure for coverage measurements in go

This commit is contained in:
ulf 2022-10-08 13:28:35 +02:00
parent b344bd8e1f
commit e6e2c62858
3 changed files with 9 additions and 3 deletions

1
go/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
coverage/

View File

@ -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
```

7
go/test-with-coverage.sh Executable file
View File

@ -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 -"