testing: expose subtest and subbenchmark functionality

Fixes #12166

Change-Id: Ie62cba2c39beb5732447ba3688c93c08ef12abb5
Reviewed-on: https://go-review.googlesource.com/18898
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
This commit is contained in:
Marcel van Lohuizen 2016-01-29 17:14:51 +01:00
parent 00a2a94c1e
commit 23a756d856
3 changed files with 10 additions and 13 deletions

View file

@ -548,9 +548,9 @@ func tRunner(t *T, fn func(t *T)) {
t.finished = true
}
// run runs f as a subtest of t called name. It reports whether f succeeded.
// Run runs f as a subtest of t called name. It reports whether f succeeded.
// Run will block until all its parallel subtests have completed.
func (t *T) run(name string, f func(t *T)) bool {
func (t *T) Run(name string, f func(t *T)) bool {
testName, ok := t.context.match.fullName(&t.common, name)
if !ok {
return true
@ -721,7 +721,7 @@ func RunTests(matchString func(pat, str string) (bool, error), tests []InternalT
}
tRunner(t, func(t *T) {
for _, test := range tests {
t.run(test.Name, test.F)
t.Run(test.Name, test.F)
}
// Run catching the signal rather than the tRunner as a separate
// goroutine to avoid adding a goroutine during the sequential