-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: testing: Export Name of Test or Benchmark #17231
Comments
This seems reasonable esp. because we have subtests and
subbenchmarks, so getting the test name is very hard (previously
it's possible to use callers, but not anymore.)
|
This makes sense, but what's your use case? |
One case would be creating subtest specific file names so that files from
different subtest will have distinctive file name (to ease debugging for,
say, finding the test responsible for left over files, which turns out to
be a big hassle for builder owners, because it's very hard to see which
test left some gotest-XXXX temporary files which gradually fill up the
partition.)
|
My use cases are simple. I want to know what test is running when I pass test functions to utility functions, and/or want to log the name of a test for recording to external services. |
Ok, sounds good to me. Please write up a brief proposal document. |
@adg Did you want a design document? As far as proposals go, it looks like this issue should be enough if I've understood the directions correctly. The change should be very simple - don't feel like a design document is really necessary, but let me know. Thanks, |
Well, just spec out here what the method looks like. On 28 September 2016 at 10:35, Sean Gerhardt notifications@github.com
|
I was thinking we could export the field. https://github.com/golang/go/blob/master/src/testing/testing.go#L269 change e.g. |
I'd be wary of doing that, lest people change the Name in a test. |
That does sound like a safer approach. What's a CL? |
A "change list" (see the contribution docs). But this is so simple that I'll do it, to save you the trouble of setting up a dev environment. |
CL https://golang.org/cl/29970 mentions this issue. |
What version of Go are you using (
go version
)?1.7
What operating system and processor architecture are you using (
go env
)?windows/amd64
What did you do?
Can't get a test name without using reflection or hard-coding name.
Test name is not exported https://github.com/golang/go/blob/master/src/testing/testing.go#L269.
What did you expect to see?
The test name exported.
e.g.
What did you see instead?
Non-exported test name.
The text was updated successfully, but these errors were encountered: