Documentation ¶
Overview ¶
Package testdeps provides access to dependencies needed by test execution.
This package is imported by the generated main package, which passes TestDeps into testing.Main. This allows tests to use packages at run time without making those packages direct dependencies of package testing. Direct dependencies of package testing are harder to write tests for.
Package testlog provides a back-channel communication path between tests and package os, so that cmd/go can see which environment variables and files a test consults.
Index ¶
- Variables
- func Getenv(name string)
- func Initialized() bool
- func MatchTag(name string) (ok bool, matched bool, actualName string)
- func NewEventWriter(runner Runner) *eventWriter
- func Open(name string)
- func PanicOnExit0() bool
- func SetLogger(impl Interface)
- func SetPanicOnExit0(v bool)
- func Stat(name string)
- type EventLogger
- type Interface
- type Runner
- type TestDeps
- func (TestDeps) CheckCorpus(vals []any, types []reflect.Type) error
- func (TestDeps) CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, ...) error
- func (TestDeps) ImportPath() string
- func (TestDeps) MatchString(pat, str string) (result bool, err error)
- func (TestDeps) ReadCorpus(dir string, types []reflect.Type) ([]corpusEntry, error)
- func (TestDeps) ResetCoverage()
- func (TestDeps) RunFuzzWorker(func(corpusEntry) error) error
- func (TestDeps) SetPanicOnExit0(v bool)
- func (TestDeps) SnapshotCoverage()
- func (TestDeps) StartCPUProfile(w io.Writer) error
- func (TestDeps) StartTestLog(w io.Writer)
- func (TestDeps) StopCPUProfile()
- func (TestDeps) StopTestLog() error
- func (TestDeps) WriteProfileTo(name string, w io.Writer, debug int) error
- type TestRunner
Constants ¶
This section is empty.
Variables ¶
var EnableMatchWorkaround = true
var ImportPath string
ImportPath is the import path of the testing binary, set by the generated main function.
var RealStdout *os.File
RealStdout will point to the real stdout
Functions ¶
func MatchTag ¶
MatchTag returns ok = true if the name has a test tag. If the tag is present, then "match" will indicate if the test name matched the tagged pattern. If there is a test tag, the returned name will be the actual test name minus the tag.
If there is no tag the function returns the same given name and ok = false, matched = false.
This should only be used as a workaround until we implement a real test runner.
func NewEventWriter ¶
func NewEventWriter(runner Runner) *eventWriter
func PanicOnExit0 ¶
func PanicOnExit0() bool
PanicOnExit0 reports whether to panic on a call to os.Exit(0). This is in the testlog package because, like other definitions in package testlog, it is a hook between the testing package and the os package. This is used to ensure that an early call to os.Exit(0) does not cause a test to pass.
Types ¶
type EventLogger ¶
type EventLogger interface {
Log(message string)
}
EventLogger will log test events
type Interface ¶
type Interface interface { Getenv(key string) Stat(file string) Open(file string) Chdir(dir string) }
Interface is the interface required of test loggers. The os package will invoke the interface's methods to indicate that it is inspecting the given environment variables or files. Multiple goroutines may call these methods simultaneously.
type Runner ¶
type Runner interface { Run() AddStatistics(stats *constants.Statistics) Statistics() []constants.Statistics ClearStatistics() Match(pattern string) error PrintToStdout(yes bool) PrintOutputToEventLog(yes bool) SetEventLogger(e EventLogger) LogEvent(message string) ReportStatistics() Passed() bool Output() string }
Interface for the custom test runner (contains Golang's Run() and some other custom methods that we need for recording statistics, etc.)
func Instance ¶
func Instance(m TestRunner) Runner
GetInstance returns the runner instance. Only the first invocation of this method will set the "m". This should not matter because the testing framework currently does not let us safely create our own "m" so only one instance should always exist.
Internally the testdeck package will invoke this method with 'nil' in order to access the runner.
type TestDeps ¶
type TestDeps struct{}
TestDeps is an implementation of the testing.testDeps interface, suitable for passing to testing.MainStart.
func (TestDeps) CheckCorpus ¶ added in v1.0.1
func (TestDeps) CoordinateFuzzing ¶ added in v1.0.1
func (TestDeps) ImportPath ¶
func (TestDeps) ReadCorpus ¶ added in v1.0.1
func (TestDeps) ResetCoverage ¶ added in v1.0.1
func (TestDeps) ResetCoverage()
func (TestDeps) RunFuzzWorker ¶ added in v1.0.1
func (TestDeps) SetPanicOnExit0 ¶
SetPanicOnExit0 tells the os package whether to panic on os.Exit(0).
func (TestDeps) SnapshotCoverage ¶ added in v1.0.1
func (TestDeps) SnapshotCoverage()
func (TestDeps) StartTestLog ¶
func (TestDeps) StopCPUProfile ¶
func (TestDeps) StopCPUProfile()
func (TestDeps) StopTestLog ¶
type TestRunner ¶
type TestRunner interface {
Run() int
}
This is a custom version of Golang testing's type M (a test runner struct)