execx

package
v1.13.6 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package execx runs subprocesses through an interface a test can replace.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnscripted = errors.New("execx: no scripted response for command")

Functions

This section is empty.

Types

type Command

type Command struct {
	Name   string
	Args   []string
	Dir    string
	Env    []string
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

func (Command) String

func (c Command) String() string

type ExitError

type ExitError struct {
	Result Result
	Cmd    Command
}

func (*ExitError) Error

func (e *ExitError) Error() string

type Fake

type Fake struct {
	T         testing.TB
	Calls     []Command
	Responses map[string]Result
	Available map[string]bool
}

func NewFake

func NewFake(t testing.TB) *Fake

func (*Fake) CallLines

func (f *Fake) CallLines() []string

func (*Fake) LookPath

func (f *Fake) LookPath(name string) (string, error)

func (*Fake) Run

func (f *Fake) Run(_ context.Context, cmd Command) (Result, error)

func (*Fake) Script

func (f *Fake) Script(match string, r Result)

func (*Fake) Start

func (f *Fake) Start(_ context.Context, cmd Command) (Process, error)

type Process

type Process interface {
	Wait() (Result, error)
	Kill() error
}

type Result

type Result struct {
	ExitCode int
	Stdout   string
	Stderr   string
	Duration time.Duration
}

type Runner

type Runner interface {
	Run(ctx context.Context, cmd Command) (Result, error)
	Start(ctx context.Context, cmd Command) (Process, error)
	LookPath(name string) (string, error)
}

func System

func System() Runner

Jump to

Keyboard shortcuts

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