test

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ExeSuffix is the suffix of executable files (.exe on Windows).
	ExeSuffix string
	// Verbose controls logging of test commands.
	Verbose = flag.Bool("logs", false, "log stdin/stdout of test commands")
	// UpdateGolden controls updating test fixtures.
	UpdateGolden = flag.Bool("update", false, "update golden files")
)

Functions

This section is empty.

Types

type Case

type Case struct {
	Commands [][]string `json:"commands"`
	Skip     bool       `json:"skip"`
	Environ  []string   `json:"environ"`
	// contains filtered or unexported fields
}

Case loads a testdata.json test configuration and executes that test.

func NewCase

func NewCase(t *testing.T, dir, name string) *Case

NewCase returns a Case.

func (*Case) CompareError

func (c *Case) CompareError(errIn error, stderr string)

CompareError compares stderr to the contents of a stderr file in the test directory.

func (*Case) CompareOutput

func (c *Case) CompareOutput(stdout string)

CompareOutput compares stdout to the contents of a stdout file in the test directory.

func (*Case) InitialPath

func (c *Case) InitialPath() string

func (*Case) UpdateStdout

func (c *Case) UpdateStdout(stdout string)

UpdateStdout updates the golden file for stdout with the working result.

type Environment

type Environment struct {
	// contains filtered or unexported fields
}

Environment defines a test execution environment and captures the output.

func NewEnvironment

func NewEnvironment(t *testing.T, rootPath, wd string, run RunFunc) *Environment

NewEnvironment initializes the test Environment.

func (*Environment) AddEnv

func (te *Environment) AddEnv(e string)

func (*Environment) Cleanup

func (te *Environment) Cleanup()

func (*Environment) CopyTree

func (te *Environment) CopyTree(src string)

func (*Environment) GetStderr

func (te *Environment) GetStderr() string

GetStderr returns the captures stderr.

func (*Environment) GetStdout

func (te *Environment) GetStdout() string

GetStdout returns the captures stdout.

func (*Environment) Join

func (te *Environment) Join(args ...string) string

Join returns a path rooted at the environment's tempdir.

func (*Environment) MakeDir

func (te *Environment) MakeDir(args ...string)

func (*Environment) Run

func (te *Environment) Run(progName string, args []string) error

Run runs the tests command with args.

type RunFunc

type RunFunc func(prog string, args []string, stdout, stderr io.Writer, dir string, env []string) error

RunFunc is a function that runs a test.

Jump to

Keyboard shortcuts

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