Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/cover: incorrect coverage for source file generated by x/tools/cmd/goyacc #33690

Open
rillig opened this issue Aug 16, 2019 · 1 comment

Comments

@rillig
Copy link
Contributor

commented Aug 16, 2019

What version of Go are you using?

go version go1.12.7 windows/amd64

What did you do?

go get github.com/rillig/go-yacc-examples
cd $GOPATH/src/github.com/rillig/go-yacc-examples/json
go generate
go test -c -coverpkg=. -covermode=atomic -o asdf.cover.exe
./asdf.cover.exe -test.coverprofile asdf.cover.out

What did you expect to see?

The covered code in y.go is displayed correctly.

What did you see instead?

asdf.cover.out contains:

github.com/rillig/go-yacc-examples/json/y.go:25.0,27.0 1 0

y.go lines 25 to 27 contain:

var yyToknames = [...]string{
	"$end",
	"error",

There is no code to be covered here.

Some lines below that, y.go contains:

//line yaccpar:1

go objdump -s rillig asdf.cover.exe contains:

TEXT github.com/rillig/go-yacc-examples/json.(*yyParserImpl).Lookahead(SB) yaccpar
  yaccpar:25		0x586a00		b801000000		MOVL $0x1, AX
  yaccpar:25		0x586a05		488d0d74341e00		LEAQ something(SB), CX
  yaccpar:25		0x586a0c		f00fc101		LOCK XADDL AX, 0(CX)
  yaccpar:26		0x586a10		488b442408		MOVQ 0x8(SP), AX
  yaccpar:26		0x586a15		488b8010010000		MOVQ 0x110(AX), AX
  yaccpar:26		0x586a1c		4889442410		MOVQ AX, 0x10(SP)
  yaccpar:26		0x586a21		c3			RET

This makes me suspect that the file name yaccpar is not taken into account when generating the coverage data.

See https://youtrack.jetbrains.com/issue/GO-7513

@gopherbot gopherbot added this to the Unreleased milestone Aug 16, 2019

@bcmills bcmills changed the title x/golang/cmd/goyacc: coverage is calculated for wrong files x/tools/cmd/goyacc: coverage is calculated for wrong files Aug 19, 2019

@bcmills bcmills changed the title x/tools/cmd/goyacc: coverage is calculated for wrong files cmd/cover: incorrect coverage for source file generated by x/tools/cmd/goyacc Aug 19, 2019

@bcmills bcmills modified the milestones: Unreleased, Unplanned Aug 19, 2019

@bcmills bcmills added help wanted and removed help wanted labels Aug 19, 2019

@bcmills

This comment has been minimized.

Copy link
Member

commented Aug 19, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.