github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/testing/internal/testdeps/deps.go (about)

     1  // Copyright 2016 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.
     4  
     5  // Package testdeps provides access to dependencies needed by test execution.
     6  //
     7  // This package is imported by the generated main package, which passes
     8  // TestDeps into testing.Main. This allows tests to use packages at run time
     9  // without making those packages direct dependencies of package testing.
    10  // Direct dependencies of package testing are harder to write tests for.
    11  package testdeps
    12  
    13  import (
    14  	"github.com/shogo82148/std/internal/fuzz"
    15  	"github.com/shogo82148/std/io"
    16  	"github.com/shogo82148/std/reflect"
    17  	"github.com/shogo82148/std/time"
    18  )
    19  
    20  // TestDeps is an implementation of the testing.testDeps interface,
    21  // suitable for passing to [testing.MainStart].
    22  type TestDeps struct{}
    23  
    24  func (TestDeps) MatchString(pat, str string) (result bool, err error)
    25  
    26  func (TestDeps) StartCPUProfile(w io.Writer) error
    27  
    28  func (TestDeps) StopCPUProfile()
    29  
    30  func (TestDeps) WriteProfileTo(name string, w io.Writer, debug int) error
    31  
    32  // ImportPath is the import path of the testing binary, set by the generated main function.
    33  var ImportPath string
    34  
    35  func (TestDeps) ImportPath() string
    36  
    37  func (TestDeps) StartTestLog(w io.Writer)
    38  
    39  func (TestDeps) StopTestLog() error
    40  
    41  // SetPanicOnExit0 tells the os package whether to panic on os.Exit(0).
    42  func (TestDeps) SetPanicOnExit0(v bool)
    43  
    44  func (TestDeps) CoordinateFuzzing(
    45  	timeout time.Duration,
    46  	limit int64,
    47  	minimizeTimeout time.Duration,
    48  	minimizeLimit int64,
    49  	parallel int,
    50  	seed []fuzz.CorpusEntry,
    51  	types []reflect.Type,
    52  	corpusDir,
    53  	cacheDir string) (err error)
    54  
    55  func (TestDeps) RunFuzzWorker(fn func(fuzz.CorpusEntry) error) error
    56  
    57  func (TestDeps) ReadCorpus(dir string, types []reflect.Type) ([]fuzz.CorpusEntry, error)
    58  
    59  func (TestDeps) CheckCorpus(vals []any, types []reflect.Type) error
    60  
    61  func (TestDeps) ResetCoverage()
    62  
    63  func (TestDeps) SnapshotCoverage()