exec

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

This package provides an interface to functions and structs in the standard os/exec package to facilitate mocking.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDot       = exec.ErrDot
	ErrNotFound  = exec.ErrNotFound
	ErrWaitDelay = exec.ErrWaitDelay
)

Functions

func NewExec

func NewExec() execFacade

Types

type Cmd

type Cmd interface {
	// Access to member variables:
	Path() string
	Args() []string
	Env() []string
	Dir() string
	Stdin() io.Reader
	Stdout() io.Writer
	Stderr() io.Writer
	Process() *os.Process
	ProcessState() *os.ProcessState

	// Members:
	CombinedOutput() ([]byte, error)
	Environ() []string
	Output() ([]byte, error)
	Run() error
	Start() error
	StderrPipe() (io.ReadCloser, error)
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.ReadCloser, error)
	String() string
	Wait() error
}

type CommandOption

type CommandOption func(*cmdFacade)

func WithArgs

func WithArgs(args ...string) CommandOption

func WithCancel

func WithCancel(f func() error) CommandOption

func WithContext

func WithContext(ctxt context.Context) CommandOption

func WithDir

func WithDir(dir string) CommandOption

func WithEnv

func WithEnv(name, value string) CommandOption

func WithExtraFiles

func WithExtraFiles(files []*os.File) CommandOption

func WithStderr

func WithStderr(w io.Writer) CommandOption

func WithStdin

func WithStdin(r io.Reader) CommandOption

func WithStdout

func WithStdout(w io.Writer) CommandOption

func WithSysProcAttr

func WithSysProcAttr(spa *syscall.SysProcAttr) CommandOption

func WithWaitDelay

func WithWaitDelay(d time.Duration) CommandOption

type Error

type Error = exec.Error

type Exec

type Exec interface {
	// Functions:
	LookPath(string) (string, error)

	// Constructors:
	NewCommand(string, ...CommandOption) Cmd
}

type ExitError

type ExitError = exec.ExitError

Jump to

Keyboard shortcuts

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