]> Cypherpunks repositories - gostls13.git/commit
testing: add TB.Helper to better support test helpers
authorCaleb Spare <cespare@gmail.com>
Wed, 29 Mar 2017 22:04:40 +0000 (15:04 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 14 Apr 2017 16:47:25 +0000 (16:47 +0000)
commitbc2931372243043842161c0a60bd2f86ef9696ee
treed64c0bef02f26cde8f8ac204fb15f097627a9c65
parent6266b0f08f46de10abfb3d27748bdf1fdebcbba2
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>
src/testing/helper_test.go [new file with mode: 0644]
src/testing/helperfuncs_test.go [new file with mode: 0644]
src/testing/testing.go