Skip to content

Commit 3f07a0b

Browse files
committed
testdata/testing.go: update so it can be run with go 1.16 for comparison
1 parent b6bfadf commit 3f07a0b

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

testdata/testing.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package main
33
// TODO: also test the verbose version.
44

55
import (
6+
"errors"
7+
"io"
68
"testing"
79
)
810

@@ -33,14 +35,26 @@ var benchmarks = []testing.InternalBenchmark{}
3335

3436
var examples = []testing.InternalExample{}
3537

38+
var errMain = errors.New("testing: unexpected use of func Main")
39+
40+
// matchStringOnly is part of upstream, and is used below to provide a dummy deps to pass to MainStart
41+
// so it can be run with go (tested with go 1.16) to provide a baseline for the regression test.
42+
// See c56cc9b3b57276. Unfortunately, testdeps is internal, so we can't just use &testdeps.TestDeps{}.
43+
type matchStringOnly func(pat, str string) (bool, error)
44+
45+
func (f matchStringOnly) MatchString(pat, str string) (bool, error) { return f(pat, str) }
46+
func (f matchStringOnly) StartCPUProfile(w io.Writer) error { return errMain }
47+
func (f matchStringOnly) StopCPUProfile() {}
48+
func (f matchStringOnly) WriteProfileTo(string, io.Writer, int) error { return errMain }
49+
func (f matchStringOnly) ImportPath() string { return "" }
50+
func (f matchStringOnly) StartTestLog(io.Writer) {}
51+
func (f matchStringOnly) StopTestLog() error { return errMain }
52+
func (f matchStringOnly) SetPanicOnExit0(bool) {}
53+
3654
func main() {
37-
m := testing.MainStart(testdeps{}, tests, benchmarks, examples)
55+
m := testing.MainStart(matchStringOnly(nil), tests, benchmarks, examples)
3856
exitcode := m.Run()
3957
if exitcode != 0 {
4058
println("exitcode:", exitcode)
4159
}
4260
}
43-
44-
type testdeps struct{}
45-
46-
func (testdeps) MatchString(pat, str string) (bool, error) { return true, nil }

0 commit comments

Comments
 (0)