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: test -v does not output text from log.Println when package is passed #22113

Closed
ramya-rao-a opened this issue Oct 2, 2017 · 3 comments

Comments

@ramya-rao-a
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go 1.9

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

darwin/amd64 and windows/amd64

What did you do?

Run go test -v with package as argument for the below test

package stringutil

import "testing"
import "log"

func TestMe(t *testing.T) {
	log.Println("logging")
}

What did you expect to see?

The text from the log.Println statement

What did you see instead?

In Windows, the text from the log.Println statement gets output to stdout
In Mac, the text from the log.Println statement does NOT get output to stdout

go test on the other hand (without passing the package) does output the text from the log.Println statement even without the -v flag

@ianlancetaylor ianlancetaylor changed the title go test -v does not output text from log.Println when package is passed cmd/go: test -v does not output text from log.Println when package is passed Oct 2, 2017
@ianlancetaylor
Copy link
Contributor

Please show us the exact commands that you run. When I put the file you describe in $GOPATH/src/issue22113/x_test.go and run go test -v issue22113, I see this:

=== RUN   TestMe
2017/10/02 12:56:48 logging
--- PASS: TestMe (0.00s)
PASS
ok  	issue22113	0.038s

That is, the log.Println output does appear. It's perhaps worth noting that it does not appear on standard output; it appears on standard error. That is because the log package's standard logger outputs to standard error by default.

@ramya-rao-a
Copy link
Author

@ianlancetaylor My mistake.

I had another copy of the same project in the default GOPATH for go 1.9 on my Mac which did not have the log statements. That was the package being run.

Sorry for the trouble.

@Anoop-Goudar
Copy link

is there a way to store the output of go test command ? I am only interested in the end result, may be
just "pass" or "fail"

@golang golang locked and limited conversation to collaborators Aug 30, 2019
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

4 participants