harness

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitCommitAll

func GitCommitAll(t *testing.T, root, message string)

GitCommitAll stages and commits all files.

func InitGitRepo

func InitGitRepo(t *testing.T, root string)

InitGitRepo initializes a git repo with an initial commit.

func WriteFile

func WriteFile(t *testing.T, root, relPath, content string)

WriteFile is a helper to create files in the workspace during setup.

Types

type Scenario

type Scenario struct {
	Name   string
	Script []testutil.ScriptEntry

	// Setup is called before the scenario runs. It receives the workspace
	// root and should create any files/repos needed. Returns the prompt.
	Setup func(t *testing.T, root string) string

	// ExtraTools adds additional tools beyond the standard local tool set.
	ExtraTools []agent.AgentTool

	// SystemPrompt overrides the default system prompt.
	SystemPrompt string

	// OnRunning is called after the agent starts but before waiting for
	// completion. Use for injecting steering or follow-ups mid-run.
	OnRunning func(t *testing.T, a *agent.Agent)

	// ProviderGates blocks specific provider calls (0-indexed) until closed.
	// Use to synchronize mid-turn actions like steering/follow-ups.
	ProviderGates map[int]chan struct{}

	// Timeout for the entire scenario. Defaults to 10s.
	Timeout time.Duration

	// Assert is called after the scenario completes to verify outcomes.
	Assert func(t *testing.T, result *ScenarioResult)
}

Scenario defines a complete E2E test scenario.

type ScenarioResult

type ScenarioResult struct {
	// Events is the ordered sequence of all agent events.
	Events []agent.AgentEvent

	// Session is the final agent session state.
	Session *agent.Session

	// WorkspaceRoot is the path to the workspace directory.
	WorkspaceRoot string

	// ProviderCalls is the number of calls made to the provider.
	ProviderCalls int
	ProviderLog   []testutil.ScriptedProviderCall

	// Error is set if the scenario failed to start or errored.
	Error error
}

ScenarioResult captures all observable outcomes from a scenario run.

func Run

func Run(t *testing.T, scenario Scenario) *ScenarioResult

Run executes a single scenario and returns the result.

func (*ScenarioResult) ConversationUserMessages

func (r *ScenarioResult) ConversationUserMessages() []string

ConversationUserMessages returns all user message texts from the session.

func (*ScenarioResult) EventsOfType

func (r *ScenarioResult) EventsOfType(typ agent.AgentEventType) []agent.AgentEvent

EventsOfType returns all events matching the given type.

func (*ScenarioResult) HasEventSequence

func (r *ScenarioResult) HasEventSequence(types ...agent.AgentEventType) bool

HasEventSequence checks that the given event types appear in order (not necessarily contiguously) in the event stream.

func (*ScenarioResult) ToolCallNames

func (r *ScenarioResult) ToolCallNames() []string

ToolCallNames returns an ordered list of tool names that were started.

Jump to

Keyboard shortcuts

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