cmd

package
v1.13.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2016 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// None is a token to inform Result.Assert that the output should be empty
	None string = "<NOTHING>"
)

Variables

View Source
var Matches = &matches{}

Matches is a gocheck.Checker for comparing a Result against an Expected

View Source
var Success = Expected{}

Success is the default expected result

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	Command []string
	Timeout time.Duration
	Stdin   io.Reader
	Stdout  io.Writer
	Dir     string
	Env     []string
}

Cmd contains the arguments and options for a process to run as part of a test suite.

type Expected

type Expected struct {
	ExitCode int
	Timeout  bool
	Error    string
	Out      string
	Err      string
}

Expected is the expected output from a Command. This struct is compared to a Result struct by Result.Assert().

type Result

type Result struct {
	Cmd      *exec.Cmd
	ExitCode int
	Error    error
	// Timeout is true if the command was killed because it ran for too long
	Timeout bool
	// contains filtered or unexported fields
}

Result stores the result of running a command

func RunCmd

func RunCmd(cmd Cmd) *Result

RunCmd runs a command and returns a Result

func RunCommand

func RunCommand(command string, args ...string) *Result

RunCommand parses a command line and runs it, returning a result

func StartCmd

func StartCmd(cmd Cmd) *Result

StartCmd starts a command, but doesn't wait for it to finish

func WaitOnCmd

func WaitOnCmd(timeout time.Duration, result *Result) *Result

WaitOnCmd waits for a command to complete. If timeout is non-nil then only wait until the timeout.

func (*Result) Assert

func (r *Result) Assert(t testingT, exp Expected)

Assert compares the Result against the Expected struct, and fails the test if any of the expcetations are not met.

func (*Result) Combined

func (r *Result) Combined() string

Combined returns the stdout and stderr combined into a single string

func (*Result) Compare

func (r *Result) Compare(exp Expected) error

Compare returns an formatted error with the command, stdout, stderr, exit code, and any failed expectations

func (*Result) SetExitError

func (r *Result) SetExitError(err error)

SetExitError sets Error and ExitCode based on Error

func (*Result) Stderr

func (r *Result) Stderr() string

Stderr returns the stderr of the process as a string

func (*Result) Stdout

func (r *Result) Stdout() string

Stdout returns the stdout of the process as a string

func (*Result) String

func (r *Result) String() string

Jump to

Keyboard shortcuts

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