testcontext

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2019 License: AGPL-3.0 Imports: 16 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

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, preArgs ...string) string

Compile compiles the specified package and returns the executable name.

func (*Context) CompileC

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

CompileC compiles file as with gcc and adds the includes.

func (*Context) CompileShared

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) CompileWithLDFlagsX

func (ctx *Context) CompileWithLDFlagsX(pkg string, ldFlagsX map[string]string) string

CompileWithLDFlagsX compiles the specified package with the -ldflags flag set to "-s -w [-X <key>=<value>,...]" given the passed map and returns the executable name.

func (*Context) CompileWithVersion

func (ctx *Context) CompileWithVersion(pkg string, info version.Info) string

CompileWithVersion compiles the specified package with the version variables set to the passed version info values and returns the executable name.

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

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

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