How do I visualize code coverage information in Go GAE apps?

I am developing a server with the latest Go to GAE SDK . I run tests after every change:

goapp test -test.v=true

      

I use -cover

to record coverage as described goapp help testflag

:

goapp test -cover -test.v=true -test.coverprofile=c.out
[..]
coverage: 53.8% of statements
ok      _/var/lib/jenkins/jobs/loyalty/workspace    30.464s

      

This succeeds and prints the percentage of lines covered by the tests. However, trying to render the results doesn't work :

goapp tool cover -html=c.out
cover: can't find "app.go": cannot find package "_/home/ingo/git/loyalty/" in any of:
/home/ingo/Downloads/go_appengine_sdk_linux_amd64-1.9.10/go_appengine/goroot/src/pkg/_/home/ingo/git/loyalty (from $GOROOT)
/home/ingo/git/loyalty/src/_/home/ingo/git/loyalty (from $GOPATH)

      

Is the Cover Tool only used for non-GAE applications? Do I have to package my application differently in order to visualize the coverage results?

I have unsuccessfully asked this on golang-nuts before.

+3


source to share


1 answer


There is an open issue related to this. As a temporary workaround, I run sed between collecting and rendering the coverage results.



goapp test -cover -test.v=true -test.coverprofile=c.out
sed -i -e "s#.*/\(.*\.go\)#\./\\1#" c.out
goapp tool cover -html c.out -o coverage.html

      

+4


source







All Articles