run

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PrepareCmd = func(cmd *exec.Cmd) Runnable {
	return &cmdWithStderr{cmd}
}

PrepareCmd extends exec.Cmd with extra error reporting features and provides a hook to stub command execution in tests

Functions

func SetPrepareCmd

func SetPrepareCmd(fn func(*exec.Cmd) Runnable) func()

SetPrepareCmd overrides PrepareCmd and returns a func to revert it back

Types

type CmdError

type CmdError struct {
	Stderr *bytes.Buffer
	Args   []string
	Err    error
}

CmdError provides more visibility into why an exec.Cmd had failed

func (CmdError) Error

func (e CmdError) Error() string

type CommandCallback added in v1.1.0

type CommandCallback func([]string)

type CommandStubber added in v1.1.0

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

func Stub added in v1.1.0

func Stub() (*CommandStubber, func(T))

func (*CommandStubber) Register added in v1.1.0

func (cs *CommandStubber) Register(p string, exitStatus int, output string, callbacks ...CommandCallback)

type Runnable

type Runnable interface {
	Output() ([]byte, error)
	Run() error
}

Runnable is typically an exec.Cmd or its stub in tests

type T added in v1.1.0

type T interface {
	Helper()
	Errorf(string, ...interface{})
}

Jump to

Keyboard shortcuts

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