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 -v does not stream logs when testing multiple packages #46959
Comments
It talks about the difference between running Implementing output streaming for multiple packages is harder, for what it's worth. Like others mentioned in the original thread, output from testing multiple packages is buffered, and legibility could suffer from streaming. So my guess is that not including support for multiple packages was on purpose. All that said, I agree this should be better documented. I'd perhaps put a short paragraph in |
Similar to #27826 ? |
It would be nice to override this behavior or detect that I'm only running tests from a single package and stream. In my use cases, I'm only running some specific tests via For the curious, here are the actual testsFor the curious, here are the actual tests: https://github.com/matrix-org/complement/tree/050afc551c2695e8e055903f8e8ad6f3ecce17a0/tests ( As a workaround, I can get the log streaming behavior I want by being very selective about the files to run: Created #49195 to track a solution for this similar use case. |
I summarised my learnings in this StackOverflow answer in case someone else comes by this thread. |
A simple workaround is to loop through packages, i.e.
|
@brusdev that seems equivalent to the workaround already mentioned – |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, this reproduces on Go 1.16.5.
This also reproduces on Go 1.14, the version that introduced test log streaming.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I ran
go test -v ./...
in a Go module that has multiple packages, each with tests.What did you expect to see?
I expected to see the logs stream for the test(s) currently running.
According to the Go 1.14 release notes:
Ref: https://golang.org/doc/go1.14
What did you see instead?
The logs did not stream to stdout, but were batched until each test completed.
When I run the tests for a single package (
go test -v ./pkg1
), or if I run the tests without package parallelism (go test -p 1 -v ./...
), the logs do stream.It looks to me like this is probably behaving as intended, especially since Go 1.14 had this same behavior, but the release notes are misleading since they simply state that logs stream but not that they only stream under specific conditions.
I haven't found documentation about the interactions between log streaming and test package parallelism. I haven't found any documentation about test package parallelism either, and the help pages inside the go tool itself about the
-p
flag are difficult to find. To find a definition of it, one has to follow two references, so the path to discovering it isgo help test
, thengo help testflags
, thengo help build
.Possibly this is an opportunity for improved docs, but it's unclear to me where that would need to go.
The text was updated successfully, but these errors were encountered: