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 ¶
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 ¶
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 ¶
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 ¶
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))
}
Types ¶
This section is empty.