run

package
v0.1.0-18-g5afcef2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: BSD-3-Clause 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

This section is empty.

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

type CommandCallback func([]string)

type CommandStubber

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

CommandStubber stubs out invocations to external commands.

func Stub

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

Stub installs a catch-all for all external commands invoked from kraftkit. It returns a restore func that, when invoked from tests, fails the current test if some stubs that were registered were never matched.

func (*CommandStubber) Register

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

Register a stub for an external command. Pattern is a regular expression, output is the standard output from a command. Pass callbacks to inspect raw arguments that the command was invoked with.

type Runnable

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

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

type T

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