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

x/tools/cmd/cover or cmd/yacc: go tool cover -html shows all lines in yacc generated code as "not tracked" #7483

Open
gopherbot opened this issue Mar 6, 2014 · 8 comments

Comments

@gopherbot
Copy link

commented Mar 6, 2014

by hwang.dev:

What steps reproduce the problem?
1. run ./test.sh in the attachment:
    go tool yacc -p expr -o expr_auto.go expr.y
    go test -coverprofile profile.cov
    go tool cover -html profile.cov

2. In the opened browser, select "parser.go" in the drop-down list.

What happened?
All the code lines are grey ("not tracked").

What should have happened instead?
Some lines are green (covered) or red (not covered).

Please provide any additional information below:
If I modified each comment from "//line xxx" to "// line xxx" (add
an extra space between "//" and "line", then it can be tracked
correctly. So I guess that the comments like "//line xxx" somehow is a way to
tell the cover tool not to track, but why?

Attachments:

  1. expr.zip (5480 bytes)
@cznic

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2014

Comment 1:

The reason is that y_test.go contains no tests so there's nothing that go test
-coverprofile can run which means 0% coverage is expected.
#WAI
@gopherbot

This comment has been minimized.

Copy link
Author

commented Mar 6, 2014

Comment 2 by hwang.dev:

Don't conclude so fast! 0% will show a page with all RED lines!
I met this issue when I'm writing a parser with nonzero coverage tests. To show this
issue clearly, I spent additional time to modify the expr example to reproduce the
issue. How can you come up with a "reason" without actually trying it? It is fine if you
don't have much time on this issue, but just don't post such a misleading message
irresponsibly, please!
@cznic

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2014

Comment 3:

I was, of course, not discussing any other setup above what you provided as an repro
case and the accompanying info.
No tests are run by the repro so I expect that not even the information about which
lines were omitted by the tests (RED) is thus available. What is the size of profile.cov?
#WAI
@gopherbot

This comment has been minimized.

Copy link
Author

commented Mar 6, 2014

Comment 4 by hwang.dev:

> so I expect ...
You expect A but it actually does B, what's the point of your expectation?
> What is the size of profile.cov?
Try for yourself or just leave it.
I have attached an updated test case.

Attachments:

  1. expr.zip (5407 bytes)
@cznic

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2014

Comment 5:

"You expect A but it actually does B". What is B?
People can nowadays respond from a phone. Some phones can download a zip file and view
its content. Not many phones can run go test, though. The question about the file size
is a tech question. The answer to the question is, unfortunately, not technical at all.
This should be a technical discussion, please do not repeatedly attempt to divert it to
anything else. Thank you.
@gopherbot

This comment has been minimized.

Copy link
Author

commented Mar 6, 2014

Comment 6 by hwang.dev:

Thanks for your efforts spending on this issue even without a Go environment. The issue
is not urgent and it already has a workaround (add an extra space to the comment), so
I'm not waiting for it to be fixed. (If it is urgent I would rather fix it myself and
submit a patch).
I posted the issue because I think it might be interesting to understand what exact "go
cover" does with the comments with special format "//line xxx", if one of the authors of
"go cover" happens to see and answer it.
I'm sorry for my impatience. The issue is simple and obvious if you actually run it.
More words just don't help.
@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented May 9, 2014

Comment 7:

Labels changed: added repo-main, release-none.

Status changed to Accepted.

@ncw

This comment has been minimized.

Copy link
Contributor

commented Nov 30, 2014

Comment 8:

I just came across this issue with 1.4rc1
I've just been trying to run coverage on a parser generated with go tool yacc.
  //go:generate go tool yacc -v y.output grammar.y
The "go tool cover -html" flag shows the generated "y.go" file as expected, but it
doesn't have any coverage information in it.  I guess this is because of the "//line
grammar.y:123" directives which have redirected the coverage info "grammar.y".  However
grammar.y isn't visible in the html view.
go tool cover -func z.cover
shows stuff for y.go not grammar.y

@rsc rsc added this to the Unplanned milestone Apr 10, 2015

@rsc rsc removed release-none labels Apr 10, 2015

@mikioh mikioh changed the title go.tools/cmd/cover or cmd/yacc: go tool cover -html shows all lines in yacc generated code as "not tracked" x/tools/cmd/cover or cmd/yacc: go tool cover -html shows all lines in yacc generated code as "not tracked" Aug 5, 2015

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