aboutsummaryrefslogtreecommitdiff
path: root/src/testing/helper_test.go
diff options
context:
space:
mode:
authorCaleb Spare <cespare@gmail.com>2021-08-28 16:06:43 -0700
committerIan Lance Taylor <iant@golang.org>2021-09-16 23:50:23 +0000
commit4efdaa7bc7220fad0177842d0009285ca429a823 (patch)
tree478323e4724c4134dae1c0f3b9d3d320f618f248 /src/testing/helper_test.go
parente09dcc211a338450d3f680fe39abc13b79ddbb29 (diff)
downloadgo-4efdaa7bc7220fad0177842d0009285ca429a823.tar.gz
go-4efdaa7bc7220fad0177842d0009285ca429a823.zip
testing: skip panics when picking the line number for decoration
Fixes #31154 Change-Id: I4cfd98b5e79f1abdc93044fb66855ac2cc0a9a49 Reviewed-on: https://go-review.googlesource.com/c/go/+/345909 Run-TryBot: Caleb Spare <cespare@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Carlos Amedee <carlos@golang.org>
Diffstat (limited to 'src/testing/helper_test.go')
-rw-r--r--src/testing/helper_test.go35
1 files changed, 3 insertions, 32 deletions
diff --git a/src/testing/helper_test.go b/src/testing/helper_test.go
index b27fd62ee8..6175410f18 100644
--- a/src/testing/helper_test.go
+++ b/src/testing/helper_test.go
@@ -33,6 +33,9 @@ helperfuncs_test.go:45: 5
helperfuncs_test.go:21: 6
helperfuncs_test.go:44: 7
helperfuncs_test.go:56: 8
+--- FAIL: Test/sub2 (?s)
+helperfuncs_test.go:71: 11
+helperfuncs_test.go:75: recover 12
helperfuncs_test.go:64: 9
helperfuncs_test.go:60: 10
`
@@ -71,38 +74,6 @@ func TestTBHelperParallel(t *T) {
}
}
-func TestTBHelperLineNumer(t *T) {
- var buf bytes.Buffer
- ctx := newTestContext(1, newMatcher(regexp.MatchString, "", ""))
- t1 := &T{
- common: common{
- signal: make(chan bool),
- w: &buf,
- },
- context: ctx,
- }
- t1.Run("Test", func(t *T) {
- helperA := func(t *T) {
- t.Helper()
- t.Run("subtest", func(t *T) {
- t.Helper()
- t.Fatal("fatal error message")
- })
- }
- helperA(t)
- })
-
- want := "helper_test.go:92: fatal error message"
- got := ""
- lines := strings.Split(strings.TrimSpace(buf.String()), "\n")
- if len(lines) > 0 {
- got = strings.TrimSpace(lines[len(lines)-1])
- }
- if got != want {
- t.Errorf("got output:\n\n%v\nwant:\n\n%v", got, want)
- }
-}
-
type noopWriter int
func (nw *noopWriter) Write(b []byte) (int, error) { return len(b), nil }