run

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 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

This section is empty.

Types

type CmdError

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

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

func (CmdError) Error

func (e CmdError) Error() string

func (CmdError) Unwrap

func (e CmdError) Unwrap() error

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 azdo. 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
JackTT - Gopher 🇻🇳