1 // Copyright 2017 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 func TestTBHelper(t
*T
) {
15 ctx
:= newTestContext(1, newMatcher(regexp
.MatchString
, "", ""))
18 signal
: make(chan bool),
23 t1
.Run("Test", testHelper
)
25 want
:= `--- FAIL: Test (?s)
26 helperfuncs_test.go:12: 0
27 helperfuncs_test.go:33: 1
28 helperfuncs_test.go:21: 2
29 helperfuncs_test.go:35: 3
30 helperfuncs_test.go:42: 4
31 helperfuncs_test.go:47: 5
32 --- FAIL: Test/sub (?s)
33 helperfuncs_test.go:50: 6
34 helperfuncs_test.go:21: 7
35 helperfuncs_test.go:53: 8
37 lines
:= strings
.Split(buf
.String(), "\n")
38 durationRE
:= regexp
.MustCompile(`\(.*\)$`)
39 for i
, line
:= range lines
{
40 line
= strings
.TrimSpace(line
)
41 line
= durationRE
.ReplaceAllString(line
, "(?s)")
44 got
:= strings
.Join(lines
, "\n")
46 t
.Errorf("got output:\n\n%s\nwant:\n\n%s", got
, want
)
50 func TestTBHelperParallel(t
*T
) {
52 ctx
:= newTestContext(1, newMatcher(regexp
.MatchString
, "", ""))
55 signal
: make(chan bool),
60 t1
.Run("Test", parallelTestHelper
)
62 lines
:= strings
.Split(strings
.TrimSpace(buf
.String()), "\n")
64 t
.Fatalf("parallelTestHelper gave %d lines of output; want 6", len(lines
))
66 want
:= "helperfuncs_test.go:21: parallel"
67 if got
:= strings
.TrimSpace(lines
[1]); got
!= want
{
68 t
.Errorf("got output line %q; want %q", got
, want
)