-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Milestone
Description
by ivan.ukhov:
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
Attachments:
- main.go (219 bytes)
- main_test.go (75 bytes)
- cover.out (124 bytes)
- cover.html (2217 bytes)
- main.cgo1.go (605 bytes)