-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/cover: incorrect coverage for source file generated by x/tools/cmd/goyacc #33690
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
Comments
Run |
@adam-azarchs I tried your suggestion, and it works partially. The thing that works is the coverage, in that I found two branches of my code that are not yet covered. The downside though is that to achieve 100% code coverage, I would now have to cover all goyacc error cases now, and maybe even trigger impossible situations. The goyacc code has worked for me, and I'm not willing to test it thoroughly. Therefore I consider the |
My point is that this isn't a problem with In terms of code coverage numbers, I'm not sure what you're expecting. Do you want to cover everything in the generated code or not? It sounds like you don't, but then what exactly do you want to ensure coverage of? If there is a |
I want to ensure coverage of all the code I have written myself in the yacc source file, as you said. I think that the output of gocover should include the yacc source file. I usually make the code in the yacc source file minimal, as that file has less IDE support than regular go source. Therefore having the coverage of the individual lines in the yacc file is sufficient to me. I don't need the column information. |
Without these line numbers, code coverage can be measured more accurately, but that's likely a bug in gocover. See golang/go#33690.
Not sure if this is what you're talking about but #32200 caused most of that code not to be covered. Have you tried with go1.13? |
That's definitely an interesting bug, but not my point here. I tried again with go1.13, and the coverage data still references the wrong locations. I updated the original description, trying to express myself clearer. |
What version of Go are you using?
go version go1.12.7 windows/amd64
What did you do?
What did you expect to see?
The
coverage.out
file contains coverage markers forjson.y
, as that is where the source code comes from, according to the//line
comments.What did you see instead?
The
coverage.out
file contains:y.go lines 25 to 27 contain:
There is no code to be covered here, and these lines do not form a block at all.
Some lines below that, y.go contains:
The output of
go tool objdump
on the test executable contains: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
The text was updated successfully, but these errors were encountered: