Documentation
¶
Overview ¶
Package execx wraps os/exec behind an interface, so command sequences can be asserted in tests without git, docker or node being installed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MissingBinary ¶ added in v0.10.0
MissingBinary names the executable a command could not find, or "" for any other failure, so a caller can say where that binary is meant to come from.
func ShellQuote ¶ added in v0.7.0
ShellQuote wraps s in single quotes unless every character is one a shell takes literally, which covers paths, flags and key=value.
func WaitFor ¶ added in v0.5.0
func WaitFor(ctx context.Context, r Runner, label string, attempts int, interval time.Duration, probe Cmd) error
WaitFor runs probe until it succeeds, which is how a container is told to be ready: docker reports one started long before what runs inside it answers. The last failure is wrapped, since it is the only thing that says why.
Types ¶
type Call ¶
type Call struct {
Name string
Args []string
Dir string
Env []string
// Bounded says the context carried a deadline: a command asking docker
// something must never be able to hang wtm, and tests assert it here.
Bounded bool
// Cancelled says the context was already done: such a command fails before
// it starts, which a cleanup must never do.
Cancelled bool
}
type Cmd ¶
type Cmd struct {
Name string
Args []string
Dir string
Env []string // extra variables, appended to the current environment
// Stdout, when set, receives the command output instead of it being
// captured in Result (used to stream pg_dump straight to a file).
Stdout io.Writer
// Live mirrors output to the terminal, for long commands like docker build.
Live bool
// Interactive hands the process the terminal itself, so that a shell or
// any prompt-driven command behaves normally. Nothing is captured.
Interactive bool
}
type Error ¶
type Error struct {
Cmd string
ExitCode int
Stderr string
Err error
// Live says the output already reached the terminal as the command ran.
// The error then keeps the last line alone, the diagnosis, rather than
// printing the whole block a second time.
Live bool
}
Error carries the underlying command failure so callers can wrap it with their own context without losing the original message.
type Fake ¶
Fake records commands and replies with whatever Handler returns. It lives in the non-test build so every package can drive its own sequences.