diff options
author | Dan Kegel <[email protected]> | 2022-01-09 08:37:36 -0800 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-01-12 08:59:09 +0100 |
commit | 798085e866c683aeaa9e0c648d5af230ab45fd62 (patch) | |
tree | 7429238dd64457a804099f1fd0d771214e194b1c /testdata/testing.go | |
parent | 69bf6e3c897c6513e986d8ee2baa7131f59fd853 (diff) | |
download | tinygo-798085e866c683aeaa9e0c648d5af230ab45fd62.tar.gz tinygo-798085e866c683aeaa9e0c648d5af230ab45fd62.zip |
testdata/testing.go: update so it can be run with go 1.16 for comparison
Diffstat (limited to 'testdata/testing.go')
-rw-r--r-- | testdata/testing.go | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/testdata/testing.go b/testdata/testing.go index 6b549da8c..9e0a018d1 100644 --- a/testdata/testing.go +++ b/testdata/testing.go @@ -3,6 +3,8 @@ package main // TODO: also test the verbose version. import ( + "errors" + "io" "testing" ) @@ -33,14 +35,26 @@ var benchmarks = []testing.InternalBenchmark{} var examples = []testing.InternalExample{} +var errMain = errors.New("testing: unexpected use of func Main") + +// matchStringOnly is part of upstream, and is used below to provide a dummy deps to pass to MainStart +// so it can be run with go (tested with go 1.16) to provide a baseline for the regression test. +// See c56cc9b3b57276. Unfortunately, testdeps is internal, so we can't just use &testdeps.TestDeps{}. +type matchStringOnly func(pat, str string) (bool, error) + +func (f matchStringOnly) MatchString(pat, str string) (bool, error) { return f(pat, str) } +func (f matchStringOnly) StartCPUProfile(w io.Writer) error { return errMain } +func (f matchStringOnly) StopCPUProfile() {} +func (f matchStringOnly) WriteProfileTo(string, io.Writer, int) error { return errMain } +func (f matchStringOnly) ImportPath() string { return "" } +func (f matchStringOnly) StartTestLog(io.Writer) {} +func (f matchStringOnly) StopTestLog() error { return errMain } +func (f matchStringOnly) SetPanicOnExit0(bool) {} + func main() { - m := testing.MainStart(testdeps{}, tests, benchmarks, examples) + m := testing.MainStart(matchStringOnly(nil), tests, benchmarks, examples) exitcode := m.Run() if exitcode != 0 { println("exitcode:", exitcode) } } - -type testdeps struct{} - -func (testdeps) MatchString(pat, str string) (bool, error) { return true, nil } |