Documentation
¶
Overview ¶
Reimport the go-cmp package as the name 'cmp' conflicts with the cmp instruction in the vm.
Copyright 2021 Google Inc. All Rights Reserved. This file is available under the Apache license.
Copyright 2019 Google Inc. All Rights Reserved. This file is available under the Apache license.
Index ¶
- Constants
- func AllowUnexported(types ...interface{}) cmp.Option
- func Chdir(tb testing.TB, dir string)
- func Diff(a, b interface{}, opts ...cmp.Option) string
- func DoOrTimeout(do func() (bool, error), deadline, interval time.Duration) (bool, error)
- func ExpectExpvarDeltaWithDeadline(tb testing.TB, name string, want int64) func()
- func ExpectMapExpvarDeltaWithDeadline(tb testing.TB, name, key string, want int64) func()
- func ExpectNoDiff(tb testing.TB, a, b interface{}, opts ...cmp.Option) bool
- func FatalIfErr(tb testing.TB, err error)
- func FreePort(tb testing.TB) int
- func IgnoreFields(typ interface{}, names ...string) cmp.Option
- func IgnoreUnexported(types ...interface{}) cmp.Option
- func LinesReceived(lines <-chan *logline.LogLine) (r []*logline.LogLine)
- func OpenLogFile(tb testing.TB, name string) *os.File
- func SetFlag(tb testing.TB, name, value string)
- func SkipIfRoot(tb testing.TB)
- func SkipIfShort(tb testing.TB)
- func SortSlices(lessFunc interface{}) cmp.Option
- func TestGetExpvar(tb testing.TB, name string) expvar.Var
- func TestOpenFile(tb testing.TB, name string) *os.File
- func TestTempDir(tb testing.TB) string
- func TimeoutTest(timeout time.Duration, f func(t *testing.T)) func(t *testing.T)
- func WriteString(tb testing.TB, f io.StringWriter, str string) int
Constants ¶
const RaceDetectorMultiplier = 1.0
Variables ¶
This section is empty.
Functions ¶
func AllowUnexported ¶
func Chdir ¶
Chdir changes current working directory, and registers a cleanup function to return to the previous directory.
func DoOrTimeout ¶
DoOrTimeout runs a check function every interval until deadline, unless the check returns true. The check should return false otherwise. If the check returns an error the check is immediately failed.
func ExpectExpvarDeltaWithDeadline ¶
ExpectExpvarDeltaWithDeadline returns a deferrable function which tests if the expvar metric with name has changed by delta within the given deadline, once the function begins. Before returning, it fetches the original value for comparison.
func ExpectMapExpvarDeltaWithDeadline ¶
ExpectMapExpvarMetricDeltaWithDeadline returns a deferrable function which tests if the expvar map metric with name and key has changed by delta within the given deadline, once the function begins. Before returning, it fetches the original value for comparison.
func ExpectNoDiff ¶
ExpectNoDiff tests to see if the two interfaces have no diff. If there is no diff, the retrun value is true. If there is a diff, it is logged to tb and an error is flagged, and the return value is false.
func FatalIfErr ¶
FatalIfErr fails the test with a fatal error if err is not nil.
func IgnoreFields ¶
func IgnoreUnexported ¶
func OpenLogFile ¶
OpenLogFile creates a new file that emulates being a log.
func SetFlag ¶
SetFlag sets the value of the commandline flag, and registers a cleanup function that restores the flag value.
func SkipIfRoot ¶
func SkipIfShort ¶
func SortSlices ¶
func TestGetExpvar ¶
TestGetExpvar fetches the expvar metric `name`, and returns the expvar. Callers are responsible for type assertions on the returned value.
func TestOpenFile ¶
TestOpenFile creates a new file called name and returns the opened file.
func TestTempDir ¶
TestTempDir creates a temporary directory for use during tests, returning the pathname.
func TimeoutTest ¶
TimeoutTest returns a test function that executes f with a timeout, If the test does not complete in time the test is failed. This lets us set a per-test timeout instead of the global `go test -timeout` coarse timeout.
func WriteString ¶
Types ¶
This section is empty.