mockexe

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mockexe lets a test binary impersonate an agent CLI: call Main() first in TestMain; in child processes spawned with Env(spec) it performs the configured behavior and exits. This replaces sh mock scripts so adapter/daemon tests run on Windows.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Env

func Env(s Spec) []string

Env returns the environment entries that make a child running the test binary behave per spec. Append to os.Environ() — or set them via t.Setenv so children inherit them implicitly.

func Main

func Main()

Main must be the first call in TestMain. No-op in the test process; in a child spawned with Env(spec) it acts as the mock and never returns.

Types

type Spec

type Spec struct {
	Stdout  string
	Stderr  string
	Exit    int
	DelayMs int
}

Spec describes the mocked CLI's behavior. In Stdout/Stderr the token {LAST} is replaced with the process's last argv element — that is how dash-prompt tests prove the prompt arrived intact.

Jump to

Keyboard shortcuts

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