lltest

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package lltest provides test doubles for the leyline daemon wire: an in-process fake speaking the line-delimited JSON UDS protocol, and a gated spawner for the SHA-pinned real binary. Tests point mache at either via t.Setenv("LEYLINE_SOCKET", sock) — leyline.DiscoverOrStart honors that env var before any spawn/download logic runs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FakeDaemon

func FakeDaemon(t *testing.T, handler Handler) string

FakeDaemon starts a Unix-domain-socket server that speaks the daemon's line-delimited JSON protocol, answering every request via handler. It returns the socket path; callers wire it up with t.Setenv("LEYLINE_SOCKET", sock). The server tolerates probe connections that close without sending (DiscoverOrStart's liveness check does exactly that). Shutdown is registered via t.Cleanup.

func IngestSourceViaLeyline

func IngestSourceViaLeyline(t *testing.T, engine *ingest.Engine, srcPath string)

IngestSourceViaLeyline is the test-side equivalent of the serve/mount source path after in-process tree-sitter removal (mache-37ae8b, ADR-0012 step 4): it parses srcPath with the pinned leyline binary into an `_ast` db, attaches an ASTWalker to engine, and ingests. Tests that previously did `engine.Ingest(sourceFileOrDir)` — which now errors because the Engine has no in-process parser — call this instead.

srcPath may be a file or a directory (leyline parse wants a directory, so a single file is staged into a temp dir first). The binary is resolved with ResolveBinary(false), so the test SKIPS rather than downloading when the pinned leyline isn't cached — mirroring every other leyline e2e test.

func ParseSourceViaLeyline added in v0.22.0

func ParseSourceViaLeyline(t *testing.T, srcPath string) (*sql.DB, string)

ParseSourceViaLeyline is the parse half of IngestSourceViaLeyline: it parses srcPath with the pinned leyline binary and returns the opened `_ast` db (closed at test cleanup) and the directory that was parsed — the path to ingest, and the root leyline keyed every source_id against. Tests that need the parse output itself, not just its projection (a count of `_ast` nodes to check the projection against), call this and ingest separately.

func StartPinnedDaemon

func StartPinnedDaemon(t *testing.T) string

StartPinnedDaemon spawns the SHA-pinned leyline binary from ~/.mache/bin/leyline as a PRIVATE daemon (own arena/control/socket in a short-lived temp dir — no interference with the shared ~/.mache arena) and returns its socket path.

Gated, never downloads: the test SKIPS when the binary is absent or its --version does not match leyline.PinnedBinaryVersion(). It deliberately does NOT fall back to a leyline on PATH — an unpinned binary produces different wire behavior than CI's SHA-verified release (mache-608a3c).

func UsePinnedDaemon

func UsePinnedDaemon(t *testing.T)

UsePinnedDaemon spawns a private pinned daemon (see StartPinnedDaemon) and points LEYLINE_SOCKET at it for the remainder of the test, which is how every gated e2e consumer wires the daemon into mache's discovery path.

Types

type Binary added in v0.22.0

type Binary struct {
	// Path to the executable.
	Path string
	// Version as the binary reports it, without a leading "v". Read from
	// --version rather than assumed, because the point of an override is that
	// it is NOT the pin.
	Version string
	// Override is true when Path came from leyline.BinaryOverrideEnv rather
	// than the pinned cache. Callers that assert pinned behaviour must consult
	// it: an override deliberately runs a different producer, so an assertion
	// phrased as "equals the pin" is meaningless and must become a report.
	Override bool
}

Binary is which leyline a gated test resolved, and how.

func ResolveBinaryOrSkip added in v0.22.0

func ResolveBinaryOrSkip(t TestingT) Binary

ResolveBinaryOrSkip reports decideBinary's answer through t: fatal reasons fail, everything else skips, and an override announces itself so a green run can never be read as green against the pin.

type Handler

type Handler func(req map[string]any) any

Handler produces the response object for one decoded request. The returned value is JSON-marshalled and written back as a single line.

type TestingT added in v0.22.0

type TestingT interface {
	Helper()
	Logf(format string, args ...any)
	Skipf(format string, args ...any)
	Fatalf(format string, args ...any)
}

TestingT is the subset of *testing.T the resolver reports through. *testing.T satisfies it, so every existing caller is unchanged.

Jump to

Keyboard shortcuts

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