Documentation ¶
Overview ¶
Package starlarkassert is an extension of go.starlark.net/starlarktest to integrate into go's testing pacakge.
Index ¶
- func BenchFile(b *testing.B, filename string, src interface{}, globals starlark.StringDict, ...)
- func InParallel(t testing.TB, _ *starlark.Thread) func()
- func RunBenches(b *testing.B, pattern string, globals starlark.StringDict, opts ...TestOption)
- func RunTests(t *testing.T, pattern string, globals starlark.StringDict, opts ...TestOption)
- func TestFile(t *testing.T, filename string, src interface{}, globals starlark.StringDict, ...)
- type Bench
- type Diffable
- type MatchStringOnly
- func (f MatchStringOnly) CheckCorpus([]any, []reflect.Type) error
- func (f MatchStringOnly) CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, ...) error
- func (f MatchStringOnly) ImportPath() string
- func (f MatchStringOnly) MatchString(pat, str string) (bool, error)
- func (f MatchStringOnly) ReadCorpus(string, []reflect.Type) ([]corpusEntry, error)
- func (f MatchStringOnly) ResetCoverage()
- func (f MatchStringOnly) RunFuzzWorker(func(corpusEntry) error) error
- func (f MatchStringOnly) SetPanicOnExit0(bool)
- func (f MatchStringOnly) SnapshotCoverage()
- func (f MatchStringOnly) StartCPUProfile(w io.Writer) error
- func (f MatchStringOnly) StartTestLog(io.Writer)
- func (f MatchStringOnly) StopCPUProfile()
- func (f MatchStringOnly) StopTestLog() error
- func (f MatchStringOnly) WriteProfileTo(string, io.Writer, int) error
- type Test
- type TestOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BenchFile ¶
func BenchFile(b *testing.B, filename string, src interface{}, globals starlark.StringDict, opts ...TestOption)
BenchFile runs each function with the prefix "bench_" as a b.Run func.
func RunBenches ¶
func RunBenches(b *testing.B, pattern string, globals starlark.StringDict, opts ...TestOption)
RunBenches is a local bench suite runner. Each file in the pattern glob is ran. To use add it to a Benchmark function:
func BenchmarkStarlark(b *testing.B) { globals := starlark.StringDict{} RunBenches(b, "testdata/*.star", globals) }
func RunTests ¶
func RunTests(t *testing.T, pattern string, globals starlark.StringDict, opts ...TestOption)
RunTests is a local test suite runner. Each file in the pattern glob is ran. To use add it to a Test function:
func TestStarlark(t *testing.T) { globals := starlark.StringDict{} RunTests(t, "testdata/*_test.star", globals) }
func TestFile ¶
func TestFile(t *testing.T, filename string, src interface{}, globals starlark.StringDict, opts ...TestOption)
TestFile runs each function with the prefix "test_" as a t.Run func. To run in parallel, use the InParallel option.
Types ¶
type Bench ¶
type Bench struct {
// contains filtered or unexported fields
}
Bench is passed to starlark benchmark functions. Interface is based on Go's *testing.B.
def bench_bar(b): for _ in range(b.n): ...work...
type Diffable ¶
type Diffable interface { starlark.Comparable // DiffSameType compares a value of the same Type(). // Returns a human-readable report of the difference between the two values. // Returns an empty string if the two values are equal. // Implementation should be similar to cmp.Diff(). DiffSameType(y starlark.Value) (string, error) }
A Diffable is a value that can report it's difference.
type MatchStringOnly ¶
MatchStringOnly is an implementation of the internal testing.testDeps interface. Interface is unstable and likely to break in new go versions. Current go 1.18.
func (MatchStringOnly) CheckCorpus ¶
func (f MatchStringOnly) CheckCorpus([]any, []reflect.Type) error
func (MatchStringOnly) CoordinateFuzzing ¶
func (MatchStringOnly) ImportPath ¶
func (f MatchStringOnly) ImportPath() string
func (MatchStringOnly) MatchString ¶
func (f MatchStringOnly) MatchString(pat, str string) (bool, error)
func (MatchStringOnly) ReadCorpus ¶
func (f MatchStringOnly) ReadCorpus(string, []reflect.Type) ([]corpusEntry, error)
func (MatchStringOnly) ResetCoverage ¶
func (f MatchStringOnly) ResetCoverage()
func (MatchStringOnly) RunFuzzWorker ¶
func (f MatchStringOnly) RunFuzzWorker(func(corpusEntry) error) error
func (MatchStringOnly) SetPanicOnExit0 ¶
func (f MatchStringOnly) SetPanicOnExit0(bool)
func (MatchStringOnly) SnapshotCoverage ¶
func (f MatchStringOnly) SnapshotCoverage()
func (MatchStringOnly) StartCPUProfile ¶
func (f MatchStringOnly) StartCPUProfile(w io.Writer) error
func (MatchStringOnly) StartTestLog ¶
func (f MatchStringOnly) StartTestLog(io.Writer)
func (MatchStringOnly) StopCPUProfile ¶
func (f MatchStringOnly) StopCPUProfile()
func (MatchStringOnly) StopTestLog ¶
func (f MatchStringOnly) StopTestLog() error
func (MatchStringOnly) WriteProfileTo ¶
type Test ¶
type Test struct {
// contains filtered or unexported fields
}
Test is passed to starlark testing functions. Interface is based on Go's *testing.T.
def test_foo(t): ...check...
type TestOption ¶
TestOption is called on setup with an optional cleanup func called on teardown.
func WithLoad ¶
func WithLoad(load func(*starlark.Thread, string) (starlark.StringDict, error)) TestOption
WithLoad adds a loader to the thread. If the loader returns nil, the previous loader will be called.