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/go: go test -cover output is racy #5810

Closed
robpike opened this issue Jun 29, 2013 · 2 comments
Closed

cmd/go: go test -cover output is racy #5810

robpike opened this issue Jun 29, 2013 · 2 comments

Comments

@robpike
Copy link
Contributor

robpike commented Jun 29, 2013

% go test -cover .
ok      fmt 0.048s  coverage: 91.2% of statements
% go test -cover
PASS
test coverage for fmt: 91.2% of statements
ok      fmt 0.047s(missing coverage statistics)
% 

When you don't specify packages, the output is unbuffered so you can watch it run, but
that means the buffer might not be flushed and cmd/go won't see the coverage stats, so
it can't recover them from the log.

Rethink where and how this is done.
@rsc
Copy link
Contributor

rsc commented Jul 1, 2013

Comment 1:

The failure is purely deterministic, not a race.
go test x 
has its output redirected to a pipe (and thus available for searching in the go tool)
go test
is not redirected: it is connected directly to the go command's std out and err.
The fix is probably to pass the coverage suffix ("in package xxx" or "") in testmain.go,
and then have the coverage print include the full line. Then 
go test x y
would print output like
ok x coverage: (text from pipe)
ok y coverage: (text from pipe)
but go test
would just let the test output speak for itself and would not re-echo the coverage
information.

@robpike
Copy link
Contributor Author

robpike commented Jul 9, 2013

Comment 2:

This issue was closed by revision 6d86c14.

Status changed to Fixed.

@robpike robpike self-assigned this Jul 9, 2013
@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc unassigned robpike Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants