@@ -3,6 +3,8 @@ package main
3
3
// TODO: also test the verbose version.
4
4
5
5
import (
6
+ "errors"
7
+ "io"
6
8
"testing"
7
9
)
8
10
@@ -33,14 +35,26 @@ var benchmarks = []testing.InternalBenchmark{}
33
35
34
36
var examples = []testing.InternalExample {}
35
37
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
+
36
54
func main () {
37
- m := testing .MainStart (testdeps {} , tests , benchmarks , examples )
55
+ m := testing .MainStart (matchStringOnly ( nil ) , tests , benchmarks , examples )
38
56
exitcode := m .Run ()
39
57
if exitcode != 0 {
40
58
println ("exitcode:" , exitcode )
41
59
}
42
60
}
43
-
44
- type testdeps struct {}
45
-
46
- func (testdeps ) MatchString (pat , str string ) (bool , error ) { return true , nil }
0 commit comments