...

Source file src/github.com/go-kivik/kivik/v4/kiviktest/go123testing.go

Documentation: github.com/go-kivik/kivik/v4/kiviktest

     1  // Licensed under the Apache License, Version 2.0 (the "License"); you may not
     2  // use this file except in compliance with the License. You may obtain a copy of
     3  // the License at
     4  //
     5  //  http://www.apache.org/licenses/LICENSE-2.0
     6  //
     7  // Unless required by applicable law or agreed to in writing, software
     8  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     9  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    10  // License for the specific language governing permissions and limitations under
    11  // the License.
    12  
    13  //go:build go1.23
    14  
    15  package kiviktest
    16  
    17  import (
    18  	"io"
    19  	"os"
    20  	"reflect"
    21  	"regexp"
    22  	"testing"
    23  	"time"
    24  )
    25  
    26  type corpusEntry = struct {
    27  	Parent     string
    28  	Path       string
    29  	Data       []byte
    30  	Values     []interface{}
    31  	Generation int
    32  	IsSeed     bool
    33  }
    34  
    35  // testDeps is a copy of testing.testDeps
    36  type testDeps interface {
    37  	ImportPath() string
    38  	MatchString(pat, str string) (bool, error)
    39  	SetPanicOnExit0(bool)
    40  	StartCPUProfile(io.Writer) error
    41  	StopCPUProfile()
    42  	StartTestLog(io.Writer)
    43  	StopTestLog() error
    44  	WriteProfileTo(string, io.Writer, int) error
    45  	CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, string, string) error
    46  	RunFuzzWorker(func(corpusEntry) error) error
    47  	ReadCorpus(string, []reflect.Type) ([]corpusEntry, error)
    48  	CheckCorpus([]interface{}, []reflect.Type) error
    49  	ResetCoverage()
    50  	SnapshotCoverage()
    51  }
    52  
    53  type deps struct{}
    54  
    55  var _ testDeps = &deps{}
    56  
    57  func (*deps) MatchString(pat, str string) (bool, error)         { return regexp.MatchString(pat, str) }
    58  func (*deps) StartCPUProfile(_ io.Writer) error                 { return nil }
    59  func (*deps) StopCPUProfile()                                   {}
    60  func (*deps) WriteHeapProfile(_ io.Writer) error                { return nil }
    61  func (*deps) WriteProfileTo(_ string, _ io.Writer, _ int) error { return nil }
    62  func (*deps) ImportPath() string                                { return "" }
    63  func (*deps) StartTestLog(io.Writer)                            {}
    64  func (*deps) StopTestLog() error                                { return nil }
    65  func (*deps) SetPanicOnExit0(bool)                              {}
    66  func (*deps) CheckCorpus([]interface{}, []reflect.Type) error   { return nil }
    67  func (*deps) CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, string, string) error {
    68  	return nil
    69  }
    70  func (*deps) RunFuzzWorker(func(corpusEntry) error) error              { return nil }
    71  func (*deps) ReadCorpus(string, []reflect.Type) ([]corpusEntry, error) { return nil, nil }
    72  func (*deps) ResetCoverage()                                           {}
    73  func (*deps) SnapshotCoverage()                                        {}
    74  func (*deps) InitRuntimeCoverage() (string, func(string, string) (string, error), func() float64) {
    75  	return "", nil, nil
    76  }
    77  
    78  func mainStart(tests []testing.InternalTest) {
    79  	m := testing.MainStart(&deps{}, tests, nil, nil, nil)
    80  	os.Exit(m.Run())
    81  }
    82  

View as plain text