testcontext

package
v0.24.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2019 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTimeout = 3 * time.Minute

DefaultTimeout is the default timeout used by new context

Variables

View Source
var CLibMath = Include{Standard: true, Library: "m"}

CLibMath is the standard C math library (see `man math.h`).

Functions

This section is empty.

Types

type CompileCOptions added in v0.17.0

type CompileCOptions struct {
	Dest     string
	Sources  []string
	Includes []Include
	NoWarn   bool
}

CompileCOptions stores options for compiling C source to an executable.

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

Context is a context that has utility methods for testing and waiting for asynchronous errors.

func New

func New(test TB) *Context

New creates a new test context with default timeout

func NewWithTimeout

func NewWithTimeout(test TB, timeout time.Duration) *Context

NewWithTimeout creates a new test context with a given timeout

func (*Context) Check

func (ctx *Context) Check(fn func() error)

Check calls fn and checks result

func (*Context) Cleanup

func (ctx *Context) Cleanup()

Cleanup waits everything to be completed, checks errors and goroutines which haven't ended and tries to cleanup directories

func (*Context) Compile

func (ctx *Context) Compile(pkg string) string

Compile compiles the specified package and returns the executable name.

func (*Context) CompileC added in v0.14.0

func (ctx *Context) CompileC(t *testing.T, opts CompileCOptions) string

CompileC compiles file as with gcc and adds the includes.

func (*Context) CompileShared added in v0.14.0

func (ctx *Context) CompileShared(t *testing.T, name string, pkg string) Include

CompileShared compiles pkg as c-shared. TODO: support inclusion from other directories

(cgo header paths are currently relative to package root)

func (*Context) Dir

func (ctx *Context) Dir(elem ...string) string

Dir creates a subdirectory inside temp joining any number of path elements into a single path and return its absolute path.

func (*Context) File

func (ctx *Context) File(elem ...string) string

File returns a filepath inside a temp directory joining any number of path elements into a single path and returns its absolute path.

func (*Context) Go

func (ctx *Context) Go(fn func() error)

Go runs fn in a goroutine. Call Wait to check the result

func (*Context) Wait added in v0.15.0

func (ctx *Context) Wait()

Wait blocks until all of the goroutines launched with Go are done and fails the test if any of them returned an error.

type Include added in v0.14.0

type Include struct {
	Header   string
	Library  string
	Standard bool
}

Include defines an includable library for gcc.

type TB

type TB interface {
	Name() string
	Helper()

	Log(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
}

TB is a subset of testing.TB methods

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL