Documentation
¶
Index ¶
- Constants
- func LoadPackage(env *lisp.LEnv) *lisp.LVal
- type Test
- type TestSuite
- func (s *TestSuite) Add(t *Test) error
- func (s *TestSuite) AddBenchmark(b *Test) error
- func (s *TestSuite) Benchmark(i int) *Test
- func (s *TestSuite) Benchmarks() []string
- func (s *TestSuite) Len() int
- func (s *TestSuite) MacroAssertEqual(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) MacroAssertNil(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) MacroAssertNot(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) MacroAssertNotNil(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) MacroAssertNumEq(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) MacroAssertStringEq(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) MacroBenchmarkSimple(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) MacroTestLet(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) MacroTestLetSeq(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) Macros() []*libutil.Builtin
- func (s *TestSuite) OpBenchmark(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) OpTest(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal
- func (s *TestSuite) Ops() []*libutil.Builtin
- func (s *TestSuite) Test(i int) *Test
- func (s *TestSuite) Tests() []string
Constants ¶
const DefaultPackageName = "testing"
DefaultPackageName is the package name used by LoadPackage.
const DefaultSuiteSymbol = "test-suite"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type TestSuite ¶
type TestSuite struct {
// contains filtered or unexported fields
}
TestSuite is an ordered set of named tests.
A TestSuite's own bookkeeping is safe for concurrent use, so one suite may be registered into, and read from, any number of environments at once. LoadPackage gives every environment its own suite, so the ordinary path never shares one, but NewTestSuite and EnvTestSuite are exported with no stated scope: an embedder that installs one suite into several runtimes is doing something the API permits. Evaluating a `test` or `benchmark` form writes the suite's maps, and two goroutines writing one Go map is `fatal error: concurrent map writes`, which is thrown by the runtime and cannot be recovered. The mutex below is what keeps that from being reachable. See issue #420.
What this does NOT promise is anything about running a registered test. A Test's Fun is a lambda closed over the environment that defined it, so evaluating it from a different runtime is environment sharing, which is a separate question from whether the suite is a safe container.
func EnvTestSuite ¶
EnvTestSuite returns the suite installed in env, or nil if there is none. The suite is returned by pointer and is safe to use while other environments holding the same suite are evaluating.
"None" includes a runtime that never loaded this package at all. The map lookup is nil-checked because Registry.Package returns a nil *Package for an unregistered name and Package.Get dereferences pkg.symbols, so using it unchecked turned "does this runtime have a suite?" -- the question the nil return advertises -- into a nil pointer dereference in the host. See issue #425.
func NewTestSuite ¶
func NewTestSuite() *TestSuite
NewTestSuite returns an empty suite. The result may be installed into any number of environments and used from all of them concurrently.