engine

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package engine assembles configuration, step packs, the match registry and the shared suite. Every command that works with steps (run, validate, steps, explain, mcp) builds on it so they always agree.

Index

Constants

View Source
const (
	CodePack     = "AXX-E0300"
	CodeResource = "AXX-E0301"
)

Error codes produced while assembling packs.

View Source
const CodeUnknownPack = "AXX-E0302"

CodeUnknownPack: axx-packs.yaml names a pack that is not compiled into this axx.

Variables

This section is empty.

Functions

func Compiled

func Compiled() map[string]core.Pack

Compiled returns the packs compiled into this axx, by entry.

func Register

func Register(key string, p core.Pack)

Register makes a pack compiled into this axx available under its axx-packs.yaml entry (rest, ./steps, a module path). axx builds itself with a project's packs; the builds call it before running.

Types

type Engine

type Engine struct {
	// Declared is false for a project without axx-packs.yaml: it loads no
	// packs.
	Declared bool
	Config   *config.Config
	Packs    []NamedPack
	Registry *match.Registry
	Hooks    []runner.PackHook
	Suite    *core.Suite
	Logger   *slog.Logger
	// contains filtered or unexported fields
}

Engine is an assembled axx environment.

func New

func New(opts Options) (*Engine, error)

New registers packs and builds the suite. It does not start anything.

func (*Engine) AfterRun

func (e *Engine) AfterRun(ctx context.Context) []runner.RunError

AfterRun lets packs implementing core.Finisher check the run as a whole; each returned error becomes a run error.

func (*Engine) Close

func (e *Engine) Close(ctx context.Context) error

Close releases suite resources and closes packs (reverse order).

func (*Engine) FeaturePaths

func (e *Engine) FeaturePaths(args []string) ([]string, map[string][]int, error)

FeaturePaths resolves the feature paths to load: explicit CLI args (relative to the working directory) or run.paths (relative to the config directory, default "features").

func (*Engine) Init

func (e *Engine) Init(ctx context.Context) error

Init runs suite-scoped setup for packs that need it (connection pools...).

func (*Engine) Interpolate

func (e *Engine) Interpolate(s string) string

Interpolate expands ${env:}/${sys:} references like configuration values.

func (*Engine) Invoke

func (e *Engine) Invoke(sc *core.Scenario, text string, table *core.Table, doc *core.DocString) error

Invoke runs a step by text inside a scenario, for steps that are built from other steps.

A leading Gherkin keyword is ignored.

func (*Engine) LoadFeatures

func (e *Engine) LoadFeatures(paths []string) (*feature.Set, error)

LoadFeatures parses features under paths (URIs relative to the config dir).

func (*Engine) Manifests

func (e *Engine) Manifests() map[string]core.Manifest

Manifests returns each pack's manifest.

func (*Engine) PackNames

func (e *Engine) PackNames() []string

PackNames returns registered pack names in order.

func (*Engine) Plan

func (e *Engine) Plan(pickles []*feature.Pickle) *core.Plan

Plan matches the steps of the scenarios a run will execute, for packs implementing core.Preparer.

func (*Engine) Prepare

func (e *Engine) Prepare(ctx context.Context, pickles []*feature.Pickle) error

Prepare runs the packs' before-the-apps-start setup (core.Preparer) with the plan of the given scenarios. Hosts call it before starting the apps.

func (*Engine) ResolvePath

func (e *Engine) ResolvePath(p string) (string, error)

ResolvePath resolves a resource path referenced by a step (seed file, schema, payload): absolute paths are used as-is; relative paths are searched in `resources` roots and then the config directory.

func (*Engine) ResolvePathFrom added in v0.2.16

func (e *Engine) ResolvePathFrom(dir, p string) (string, error)

ResolvePathFrom resolves a path a feature file in dir names: next to the feature file first, then as ResolvePath.

func (*Engine) ResourceRoots

func (e *Engine) ResourceRoots() []string

ResourceRoots are the directories ResolvePath looks in, in order: the `resources` roots, then the config directory.

func (*Engine) SearchDirs added in v0.2.16

func (e *Engine) SearchDirs(dir string) []string

SearchDirs are the directories a path a feature file in dir names is looked for in, in order: dir (when not empty), then the ResourceRoots.

func (*Engine) SetProperties added in v0.6.2

func (e *Engine) SetProperties(told map[string]string)

SetProperties gives the steps the properties the services and hooks told axx (lifecycle.PropertiesEnv), as ${sys:name}: over axx.yaml's, under -D's.

func (*Engine) String

func (e *Engine) String() string

String identifies the engine for debugging.

type NamedPack

type NamedPack struct {
	Name string
	Pack core.Pack
}

NamedPack is a pack with its registration name.

func CompiledPacks

func CompiledPacks() []NamedPack

CompiledPacks returns core and every pack compiled into this axx.

func Ordered

func Ordered(comp map[string]core.Pack) []NamedPack

Ordered returns core and the packs: axx's packs in catalog order, then the others by entry.

func ProjectPacks added in v0.6.1

func ProjectPacks(cfg *config.Config) ([]NamedPack, error)

ProjectPacks returns core and the packs of the project cfg is the configuration of, compiled into this axx, in the order they load: what a run of it loads, without loading them.

type Options

type Options struct {
	Config *config.Config
	Logger *slog.Logger
	// Packs overrides the pack list (tests and tools); nil means the
	// project's axx-packs.yaml.
	Packs []NamedPack
	// Selection overrides the project's axx-packs.yaml (tests). When nil,
	// the file next to axx.yaml is used; without one, no pack is loaded.
	Selection []packset.Entry
	// Compiled overrides the packs compiled into this axx (tests).
	Compiled map[string]core.Pack
	// IDE receives the lines packs announce to an IDE running axx; nil
	// when none does.
	IDE io.Writer
}

Options configures New.

Jump to

Keyboard shortcuts

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