Documentation ¶
Index ¶
Constants ¶
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 ¶
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
RealRunner is the default value of Runner and actually executes a command.
func Run ¶
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
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.