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' waits for stdout/stderr fd EOF, 'go test -v' does not #7376

Closed
daaku opened this issue Feb 21, 2014 · 1 comment
Closed

Comments

@daaku
Copy link

daaku commented Feb 21, 2014

I'm unsure what is happening, but seems like using -v changes the behavior of exec in
tests. Notably run the attached test with and without the -v to see one run pass, and
the other hang and eventually fail.

Thanks.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. http://play.golang.org/p/6R0zNv4uAN (also attached)
2. Run test with -v, and see it pass: go test -v gotestv_test.go
3. Run test without -v, and see it hang: go test gotestv_test.go

What is the expected output?

The behavior should be the same between the two. IMO the external process shouldn't
block the test run from finishing, so the behavior when using -v of the test succeeding
is the correct one.

What do you see instead?

The test hangs when not using -v.

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

Mac OS X. Also reproduced on Linux.

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

go version go1.2 darwin/amd64

Attachments:

  1. gotestv_test.go (234 bytes)
@rsc
Copy link
Contributor

rsc commented Mar 3, 2014

Comment 1:

This is happening because the one mode is waiting for an EOF on the stdout/stderr pipe,
which it won't get until the sleep subprocess exits, and the other mode is not waiting
for the EOF. In -v mode stdout/stderr is connected to the 'go test's actual
stdout/stderr, so that output shows up as soon as it is generated. This is a feature.
Unfortunately it means that you cannot tell something else has the fd open when the test
exits. I don't see any way around this, and the bug is much less significant than the
feature, so it's working as intended.

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
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