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

unclear how to consistently get all of the log output from tests #4158

Open
jmhodges opened this issue Oct 26, 2024 · 3 comments
Open

unclear how to consistently get all of the log output from tests #4158

jmhodges opened this issue Oct 26, 2024 · 3 comments

Comments

@jmhodges
Copy link
Contributor

jmhodges commented Oct 26, 2024

What version of rules_go are you using?

0.50.1

What version of gazelle are you using?

0.39.1

What version of Bazel are you using?

7.3.1

Does this issue reproduce with the latest releases of all the above?

Yes.

What operating system and processor architecture are you using?

macOS arm

What did you do?

Tried to run all of the tests in a package without caching with verbosity turned up to see all of the t.Logf lines in it.

I tried both with -test.v, and test.count and without:

$ bazel test --cache_test_results=no --test_output=all //foobar/baz:baz_test
$ bazel test --cache_test_results=no --test_output=all --test_arg="-test.v" //foobar/baz:baz_test 
$ bazel test --cache_test_results=no --test_output=all --test_arg="-test.count=1" //foobar/baz:baz_test 
$ bazel test --cache_test_results=no --test_output=all --test_arg="-test.count=1" --test_arg="-test.v" //foobar/baz:baz_test 

What did you expect to see?

All of the tests enumerated and all the log lines run by the tests like the usual go test -v command.

Output like:

$ go test -v .
=== RUN   TestGoldenPath
    baz_test.go:23: I'm here

What did you see instead?

The versions with -test.v or -test.count always just print (with --cache_test_results=no --test_output=all included, of course) will only get you the

//foobar/baz:baz_test                      PASSED in 1.0s

Dropping those and only run bazel test --cache_test_results=no --test_output=all will get you only:

==================== Test output for //foobar/baz:baz_test:
PASS
================================================================================

with the usual

//foobar/baz:baz_test                      PASSED in 1.0s

after it

@jmhodges
Copy link
Contributor Author

(Updated the summary for clarity and with gazelle 0.39.1 testing)

@fmeum
Copy link
Member

fmeum commented Oct 26, 2024

What's the content of the test log file under bazel-testlogs in these cases?

@jmhodges
Copy link
Contributor Author

jmhodges commented Oct 26, 2024

For bazel test --cache_test_results=no --test_output=all, it's the same single line of PASS. Specifically:

exec ${PAGER:-/usr/bin/less} "$0" || exit 1
Executing tests from //foobar/baz:baz_test
-----------------------------------------------------------------------------
PASS
bazel-testlogs/foobar/baz/baz_test/test.log (END)

However, the bazel test --cache_test_results=no --test_output=all --test_arg="-test.v" does output the log lines to the test log. I'm surprised by that. I would have expected test_output=all (esp with -test.v) to put the output to stdout & stderr. Perhaps I'm wrong to be surprised by that, but as day-to-day Go hacker, I was.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants