integration_test

package
v1.10.7 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package integration_test provides end-to-end integration tests for Helix's MCP tools. Tests exercise the full protocol path: MCP client -> daemon -> kernel -> tool -> response.

The Java subset (java_test.go) runs under default `go test ./...` by sharing a warm jdtls workspace across runs via test/integration/jdtlscache (Phase 48, BUG-03). Other language tests remain gated on `-tags integration`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareFixture

func PrepareFixture(tb testing.TB, lang string) string

PrepareFixture copies testdata/fixtures/{lang}/ to a temp directory and returns the destination path. Each test gets its own copy to prevent cross-test contamination.

func WaitForLS

func WaitForLS(tb testing.TB, session *mcp.ClientSession, timeout time.Duration, query string)

WaitForLS polls search_symbols until the language server has indexed the workspace. Requires non-empty results to ensure the LS has completed indexing — some servers (rust-analyzer) return empty results without error before indexing finishes. The query parameter should match a known symbol in the fixture (e.g. "main" for Go/Java, "helper" for Python/TypeScript/Rust).

Types

type Options

type Options struct {
	// WorkspaceDir is the project path to activate after startup.
	WorkspaceDir string
	// SkipLS skips waiting for language server readiness.
	SkipLS bool
	// LSTimeout is the maximum time to wait for LS readiness (default 30s).
	LSTimeout time.Duration
	// LSQuery overrides the workspace/symbol query used for readiness detection.
	// Default "main" works for Go/Java; use "helper" for Python/TypeScript/Rust.
	LSQuery string
	// Profile overrides cfg.Profile (default "full" preserves existing behavior).
	Profile string
	// Mode, if non-empty, triggers a switch_mode call after session connect.
	// Default "" uses the profile's default_mode (no switch).
	Mode string
	// MaxWorkers overrides cfg.WorkerPool.MaxWorkers (default 2 preserves existing behavior).
	MaxWorkers int
	// JdtlsDataDir, if non-empty, is exported via the HELIX_TEST_JDTLS_DATA_DIR
	// environment variable so that JdtlsAdapter.ExtraArgs uses it as jdtls's -data
	// path (shared warm workspace across test runs; Phase 48, BUG-03).
	JdtlsDataDir string
}

Options configures a test daemon instance.

type TestDaemon

type TestDaemon struct {
	Session *mcp.ClientSession
	// contains filtered or unexported fields
}

TestDaemon wraps a daemon instance with an MCP client session for integration tests.

func StartTestDaemon

func StartTestDaemon(tb testing.TB, opts Options) *TestDaemon

StartTestDaemon creates a daemon in-process, wires an MCP client via InMemoryTransports, and optionally activates a workspace with LS readiness wait.

func (*TestDaemon) LSPoolWorker

func (td *TestDaemon) LSPoolWorker(language, workspaceDir string) *lspool.Worker

LSPoolWorker returns the warm LS worker for (language, workspaceDir) from the test daemon's pool. Test-only — used by Phase 56 integration tests to reach into adapter readiness state (TestRustAnalyzer_NotificationDispatchEndToEnd, waitJavaReady). Returns nil if no matching worker is currently in the pool.

func (*TestDaemon) NewHTTPSession

func (td *TestDaemon) NewHTTPSession(t *testing.T) *mcp.ClientSession

NewHTTPSession creates an MCP client session over HTTP transport. Uses httptest.NewServer + StreamableClientTransport to validate the full HTTP serialization path (D-03/D-04).

NOTE: This intentionally keeps *testing.T (not testing.TB). Its callers are always tests (subtest-scoped HTTP transport smoke), never benchmarks, and its t.Cleanup semantics are tied to the concrete *testing.T lifecycle.

func (*TestDaemon) Stop

func (td *TestDaemon) Stop()

Stop cancels the daemon context, which stops the kernel Run goroutine and triggers pool.stopAll to shut down all LS worker processes.

Directories

Path Synopsis
Package jdtlscache resolves the warm jdtls -data directory used by the Java integration tests.
Package jdtlscache resolves the warm jdtls -data directory used by the Java integration tests.

Jump to

Keyboard shortcuts

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