Documentation ¶
Overview ¶
Package exec is intended to be a drop-in replacement for "os/exec" which can be mocked.
See the docs in `go.chromium.org/luci/common/exec/execmock` for information on how mocking exec works.
NOTE: `Command` now takes a context; this context will only be used for the purpose of mocking, but still allows you to make a Command which is not bound to the lifetime of the context (i.e. will not be automatically killed when the context is Done()).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUseConstructor = errors.New("you must use Command or CommandContext to create a usable Cmd")
ErrUseConstructor is returned from methods of Cmd if the Cmd struct was created without using Command or CommandContext.
var LookPath = exec.LookPath
LookPath searches for an executable named file in the directories named by the PATH environment variable. If file contains a slash, it is tried directly and the PATH is not consulted. The result may be an absolute path or a path relative to the current directory.
This is an alias of `"os/exec".LookPath`.
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct { // We embed the *Cmd without a field name so that users can drop in our struct // where they previously had an *"os/exec".Cmd with minimal code changes. *exec.Cmd // contains filtered or unexported fields }
Cmd behaves like an "os/exec".Cmd, except that it can be mocked using the "go.chromium.org/luci/common/exec/execmock" package.
Must be created with Command or CommandContext.
Mocking this Cmd allows the test program to substitute this Cmd invocation transparently with another, customized, subprocess.
func Command ¶
Command behaves like "os/exec".Command, except that it can be mocked via the "go.chromium.org/luci/common/exec/execmock" package.
Note that although this takes a Context, it does not bind the lifetime of the returned Cmd to `ctx`.
func CommandContext ¶
CommandContext behaves like "os/exec".CommandContext, except that it can be mocked via the "go.chromium.org/luci/common/exec/execmock" package.
func (*Cmd) CombinedOutput ¶
CombinedOutput operates the same as "os/exec".Cmd.CombinedOutput.
func (*Cmd) StderrPipe ¶
func (c *Cmd) StderrPipe() (io.ReadCloser, error)
StderrPipe operates the same as "os/exec".Cmd.StderrPipe.
func (*Cmd) StdoutPipe ¶
func (c *Cmd) StdoutPipe() (io.ReadCloser, error)
StdoutPipe operates the same as "os/exec".Cmd.StdoutPipe.
Directories ¶
Path | Synopsis |
---|---|
Package execmock allows mocking exec commands using the go.chromium.org/luci/common/exec ("luci exec") library, which is nearly a drop-in replacement for the "os/exec" stdlib library.
|
Package execmock allows mocking exec commands using the go.chromium.org/luci/common/exec ("luci exec") library, which is nearly a drop-in replacement for the "os/exec" stdlib library. |
internal
|
|
execmockctx
Package execmockctx provides the minimum interface that the `go.chromium.org/luci/common/exec` library needs to hook into the mocking system provided by `go.chromium.org/luci/common/exec/execmock` without needing to actually link the execmock code (including it's registration of the Simple runner, and the implementation of the http test server) into non-test binaries.
|
Package execmockctx provides the minimum interface that the `go.chromium.org/luci/common/exec` library needs to hook into the mocking system provided by `go.chromium.org/luci/common/exec/execmock` without needing to actually link the execmock code (including it's registration of the Simple runner, and the implementation of the http test server) into non-test binaries. |
execmockserver
Package execmockserver implements the "net/rpc" based client/server pair which is used by execmock to communicate to/from mock subprocesses.
|
Package execmockserver implements the "net/rpc" based client/server pair which is used by execmock to communicate to/from mock subprocesses. |