Skip to content

cmd/cover, cmd/go: go test reports wrong compiler error line numbers when using -coverprofile #6329

Closed
@josharian

Description

@josharian
What steps will reproduce the problem?

1. Create a test containing a syntax error, such as http://play.golang.org/p/cIDNFBtU7Z
2. go test .
3. go test . -coverprofile=c.out


What is the expected output?

Both invocations of go test report the syntax error in the same place.


What do you see instead?

$ go test .
...
./simpletest.go:8: undefined: hi
...

$ go test . -coverprofile=c.out
...
/var/folders/jw/xrvq7wz95p5bwvjyx9yc2npm09k844/T/go-build500502516/.../simpletest.go:9:
undefined: hi
...


Note that with -coverprofile, the error is (incorrectly) reported as being on line 9.

Which version are you using?  (run 'go version')

go version devel +6b0ef65315eb Wed Sep 04 13:26:49 2013 -0700 darwin/amd64


Please provide any additional information below.

Introduced since go 1.1.1.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions