You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
Consider studying the test coverage of the attached example (main.go and main_test.go).
The example relies on some C code and, thus, involves cgo. Cgo does some preprocessing
to the source code (main.cgo1.go) and, in particular, transforms the line
13 if C.check(C.int(0)) != 0 {
into
15 if _Cfunc_check(_Ctype_int(0)) != 0 {
The coverage profile reported by `go test -coverprofile cover.out` (cover.out) is given
with respect to the preprocessed code, not the original one. Consequently, some column
numbers reported in cover.out are invalid with respect to the original code. As a
result, the htmlGen function in html.go (the cover command) fails to properly detect
block boundaries, which boils down to some span tags left open (cover.html) and, hence,
incorrect highlighting in HTML.
Best wishes,
Ivan
$ go version
go version go1.3.1 darwin/amd64
rsc
changed the title
go.tools/cmd/cover: does not take into account cgo’s preprocessing
x/tools/cmd/cover: does not take into account cgo’s preprocessing
Apr 14, 2015
rsc
changed the title
x/tools/cmd/cover: does not take into account cgo’s preprocessing
cmd/cover: does not take into account cgo’s preprocessing
Nov 10, 2017
by ivan.ukhov:
Attachments:
The text was updated successfully, but these errors were encountered: