Search Gear #11- Testing and Coverage!

Thanks @rob_pike for sorting me out on cover and style.

Rule for today run ‘go fmt’ to get that go code nice and formatted to standard style conventions!


go-imports tool

http://blog.golang.org/laws-of-reflection

go test -v
go test -cover
go test -coverprofile=coverage.out
go tool cover -func=cover.out
go tool cover -html=coverage.out

http://blog.golang.org/cover

~Oh you are joking!
Simon-Harpers-iMac:searchgear sharper$ go test -cover

cover bitbucket.org/sharpic/searchgear

cover: internal error: block 3 overlaps block 4
/Users/sharper/Development/go/src/bitbucket.org/sharpic/searchgear/configure.go:#883,#1345 /Users/sharper/Development/go/src/bitbucket.org/sharpic/searchgear/configure.go:#1344,#1842
PASS
coverage: 100.0% of statements
ok bitbucket.org/sharpic/searchgear 0.013s

Tweet: #golang crew any ideas re test-cover error ‘cover: internal error: block 3 overlaps block 4’ before I stackoverflow it? Much Appreciated

@sharpic Please send me a minimal repro via a playground link if possible. There are a couple of tricky cases in the block discovery code.

Hi @rob_pike not sure how to make repo but there are just two files http://play.golang.org/p/9tOXSFUHT2 including one for testing http://play.golang.org/p/qEA9hXgEIT

Response
@sharpic Thanks. Here’s a full repro example. http://play.golang.org/p/9dfyOAe8_y
Never shown up because we run gofmt – problem is no spaces on else.

Issue 8557: go.tools/cover: confused by else without spaces

Rob Pike ‏@rob_pike 11h
@sharpic Also: Don’t use “this” and run go fmt but anyway: *this = twitter{} will clear your struct.

So constructive comments already!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s