agenttest

package
v1.0.0-alpha.18 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 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 agenttest keeps a test from starting a real coding agent. A test that runs an agent by name would otherwise start whichever claude or codex the machine has, on its owner's account.

Index

Constants

View Source
const (
	// ExitCode is the status every stub exits with.
	ExitCode = 97
	// PathBeforeStubs names the variable that holds PATH as it stood before
	// Main put the stubs first.
	PathBeforeStubs = "COSTROID_PATH_BEFORE_STUBS"
)

Variables

View Source
var Names = []string{"bunx", "claude", "codex", "copilot", "node", "npx", "opencode"}

Names are the commands that start an agent, or start a package or script that is one.

Functions

func ClaudeForPluginValidate

func ClaudeForPluginValidate(t testing.TB) func(args ...string) ([]byte, error)

ClaudeForPluginValidate finds the first claude on PATH as it stood before Main put the stubs first, and skips t when there is none. The function it returns runs that claude with args, in a settings directory of its own and with nonessential traffic off. It fails t on any args but `plugin validate` and what follows, so no test reaches a model through it.

func Main

func Main(run func() int) int

Main puts a directory that holds one stub for each of Names first on PATH, runs the tests through run and removes the directory. A test that means to run an agent names its own fake by path. A package whose tests run an agent by name calls it from TestMain:

func TestMain(m *testing.M) {
	os.Exit(agenttest.Main(m.Run))
}

func Refusal

func Refusal(name string) string

Refusal is what the stub for name prints on stderr.

Types

This section is empty.

Jump to

Keyboard shortcuts

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