testing: add TB.Helper to better support test helpers
This CL implements the proposal at https://github.com/golang/proposal/blob/master/design/4899-testing-helper.md. It's based on Josh's CL 79890043 from a few years ago: https://codereview.appspot.com/79890043 but makes several changes, most notably by using the new CallersFrames API so that it works with mid-stack inlining. Another detail came up while I was working on this: I didn't want the user to be able to call t.Helper from inside their TestXxx function directly (which would mean we'd print a file:line from inside the testing package itself), so I explicitly prevented this from working. Fixes #4899. Change-Id: I37493edcfb63307f950442bbaf993d1589515310 Reviewed-on: https://go-review.googlesource.com/38796 Run-TryBot: Caleb Spare <cespare@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Showing
src/testing/helper_test.go
0 → 100644
Please
register
or
sign in
to comment