execxtest

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package execxtest provides a fake execx.Runner that records every command instead of running it.

Index

Constants

This section is empty.

Variables

View Source
var ErrFailed = errors.New("exit status 1")

ErrFailed is a generic command failure for handlers to return.

Functions

This section is empty.

Types

type Fake

type Fake struct {
	// Handler decides the result of each Run or Output call. When nil, every
	// command succeeds with no output.
	Handler func(c execx.Cmd) ([]byte, error)
	// Installed lists the executables LookPath reports as present.
	Installed map[string]bool
	// contains filtered or unexported fields
}

Fake is an execx.Runner that records commands and answers them through Handler. The zero value succeeds for every command with empty output and reports every executable as missing from PATH.

func Install

func Install(t testing.TB) *Fake

Install replaces the execx runner with a new Fake for the duration of t. Tests using it must not run in parallel, since the runner is package-level.

func (*Fake) Calls

func (f *Fake) Calls() []execx.Cmd

Calls returns the recorded commands in order.

func (*Fake) Commands

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

Commands returns the recorded command lines, e.g. "go test -v ./...".

func (*Fake) Find

func (f *Fake) Find(prefix string) (execx.Cmd, bool)

Find returns the first recorded command whose line starts with prefix.

func (*Fake) LookPath

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

LookPath implements execx.Runner.

func (*Fake) Output

func (f *Fake) Output(c execx.Cmd) ([]byte, error)

Output implements execx.Runner.

func (*Fake) Run

func (f *Fake) Run(c execx.Cmd) error

Run implements execx.Runner.

Jump to

Keyboard shortcuts

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