exec

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2016 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const OttoSkipCleanupEnvVar = "OTTO_SKIP_CLEANUP"

OttoSkipCleanupEnvVar, when set, tells Otto to avoid cleaning up its temporary workspace files, which can be helpful for debugging.

Variables

View Source
var Runner func(*exec.Cmd) error = RealRunner

Runner is the function that is called to run a command. This can be overridden for tests. This is a low-level replacement but we use it in various helper libraries for unit testing.

Functions

func RealRunner added in v0.2.0

func RealRunner(cmd *exec.Cmd) error

RealRunner is the default value of Runner and actually executes a command.

func Run

func Run(uiVal ui.Ui, cmd *exec.Cmd) error

Run runs the given command and streams all the output to the given UI. It also connects stdin properly so that input works as expected.

func ShouldCleanup

func ShouldCleanup() bool

ShouldCleanup returns true for normal operation. It returns false if the user requested that Otto avoid cleaning up its temporary files for debugging purposes.

func TestChrunner added in v0.2.0

func TestChrunner(r func(*exec.Cmd) error) func()

TestChrunner is a helper function that can be used to temporarily change the runner. This returns a function call that should be defered to restore the runner. Example:

defer TestChrunner(newRunner)()

Types

type MockRunner added in v0.2.0

type MockRunner struct {
	// This will record the commands that are executed
	Commands []*exec.Cmd

	// This will be the return values of the errors for the commands
	// that are executed, in the order they're called. If this is empty
	// or shorter than the command, a nil error is returned.
	CommandErrs []error

	// This will be written to the stdout when this command runs
	CommandOutput []string
}

MockRunner is a Runner implementation that records the calls. The Runner can be set to the MockRunner's Run function.

func (*MockRunner) Run added in v0.2.0

func (r *MockRunner) Run(cmd *exec.Cmd) error

Jump to

Keyboard shortcuts

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