You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
proposal: testing: Export Name of Test or Benchmark #17231
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.)
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.
@adghttps://github.com/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.
I'd be wary of doing that, lest people change the Name in a test.
Safer would be to add a Name() string method to *testing.T and *testing.B, I think.
Care to send a CL?
Activity
minux commentedon Sep 26, 2016
adg commentedon Sep 26, 2016
This makes sense, but what's your use case?
minux commentedon Sep 27, 2016
sgerhardt commentedon Sep 27, 2016
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.
adg commentedon Sep 27, 2016
Ok, sounds good to me. Please write up a brief proposal document.
seangerhardt-wf commentedon Sep 28, 2016
@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,
Sean
adg commentedon Sep 28, 2016
Well, just spec out here what the method looks like.
On 28 September 2016 at 10:35, Sean Gerhardt notifications@github.com
wrote:
sgerhardt commentedon Sep 28, 2016
I was thinking we could export the field. https://github.com/golang/go/blob/master/src/testing/testing.go#L269 change
nametoNamee.g.
Name string // Name of test or benchmark.adg commentedon Sep 28, 2016
I'd be wary of doing that, lest people change the Name in a test.
Safer would be to add a
Name() stringmethod to*testing.Tand*testing.B, I think.Care to send a CL?
sgerhardt commentedon Sep 28, 2016
That does sound like a safer approach. What's a CL?
adg commentedon Sep 28, 2016
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.
gopherbot commentedon Sep 28, 2016
CL https://golang.org/cl/29970 mentions this issue.