Documentation
¶
Index ¶
- func DeriveSeed(globalSeed int64, parts ...string) uint64
- func NewDeterministicRandV2(globalSeed int64, parts ...string) *randv2.Rand
- func RunLayers(ctx context.Context, layers [][]string, exec LayerExecutor) error
- type ActiveScenario
- type DeterministicRand
- type EventSink
- type LayerExecutor
- type Options
- type Runner
- type ScenarioState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeriveSeed ¶
DeriveSeed deterministically derives a new seed from global seed and parts.
func NewDeterministicRandV2 ¶
NewDeterministicRandV2 returns a deterministic math/rand/v2 source.
Types ¶
type ActiveScenario ¶
type ActiveScenario = report.ActiveScenario
ActiveScenario is re-exported from report so the EventSink contract reads as a single type. The data lives in the report package because runtime already imports report and not the other way around.
type DeterministicRand ¶
type DeterministicRand struct {
// contains filtered or unexported fields
}
DeterministicRand is a deterministic pseudo-random generator.
func NewDeterministicRand ¶
func NewDeterministicRand(globalSeed int64, parts ...string) *DeterministicRand
NewDeterministicRand returns deterministic random source.
func (*DeterministicRand) Intn ¶
func (d *DeterministicRand) Intn(n int) int
Intn returns a deterministic pseudo-random integer in [0,n).
type EventSink ¶
type EventSink interface {
// SuiteStarted fires once, before any scenario goroutine is spawned.
SuiteStarted(totalScenarios, parallel int, seed int64)
// ScenarioStarted fires when a scenario actually begins executing
// (after waiting on the parallelism semaphore — so "starting" really
// means "running now", not "queued").
ScenarioStarted(name string)
// ScenarioEnded fires when a scenario finishes (pass, fail, or skip).
// failureMessage is empty unless status == StatusFail.
ScenarioEnded(name string, status report.Status, duration time.Duration, failureMessage string)
// Heartbeat fires from the runtime's ticker goroutine when
// Options.HeartbeatInterval > 0. The active slice lists scenarios
// still in flight, each with the wall-clock elapsed since they
// started. The slice is empty when nothing is running, in which
// case the sink should generally stay quiet.
Heartbeat(active []ActiveScenario)
// SuiteEnded fires once, after every scenario has ended.
SuiteEnded(duration time.Duration)
}
EventSink receives runtime progress events as they happen. Implementations must be safe for concurrent calls — scenarios run in parallel and emit events from their own goroutine. A nil sink is allowed: the runner checks before dispatching.
The sink is the only observability surface available before runner.Run returns. PrintConsole runs after the whole suite finishes, so a hang in one scenario would otherwise produce zero output — see runner.Run.
type LayerExecutor ¶
LayerExecutor executes one named unit.
type Options ¶
type Options struct {
Seed int64
Parallel int
Tags []string
Scenario string
// ProjectDir is the absolute project / repository root, exposed as
// project.dir and used as a read-only allowed root by the path resolver.
// Empty defaults to the current working directory.
ProjectDir string
// ArtifactsBase is the root under which per-scenario workspaces are
// created (<base>/scenarios/<scenario>). Empty defaults to
// artifacts.DefaultBase ("build/artifacts").
ArtifactsBase string
// Events optionally receives progress events as scenarios start and
// end. Nil disables streaming (the historical behavior). The sink must
// be safe for concurrent calls.
Events EventSink
// HeartbeatInterval, when > 0 and Events is non-nil, spawns a ticker
// that calls Events.Heartbeat with the list of in-flight scenarios at
// each tick. Used by --verbose to surface slow scenarios that would
// otherwise stay quiet between their start and end lines.
HeartbeatInterval time.Duration
}
Options controls runtime execution.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner executes a suite.
type ScenarioState ¶
type ScenarioState struct {
// contains filtered or unexported fields
}
ScenarioState stores mutable runtime values for one scenario.
func NewScenarioState ¶
func NewScenarioState(stepNames []string, seed int64, workdir, artifactsDir string) *ScenarioState
NewScenarioState creates state with known step keys pre-filled as empty objects. seed is the suite seed, carried here so providers that need deterministic derived values (e.g. the mail Message-ID) can reach it without threading it through the whole execution call chain. workdir / artifactsDir are the scenario workspace roots; the save / file / exec paths resolve against them. Both are absolute, created before the scenario's steps run.
func (*ScenarioState) ArtifactsDir ¶
func (s *ScenarioState) ArtifactsDir() string
ArtifactsDir returns the absolute per-scenario artifacts directory.
func (*ScenarioState) GetResultMap ¶
func (s *ScenarioState) GetResultMap() map[string]cty.Value
GetResultMap clones result map.
func (*ScenarioState) Seed ¶
func (s *ScenarioState) Seed() int64
Seed returns the suite seed for deterministic derivations.
func (*ScenarioState) SetStepResult ¶
func (s *ScenarioState) SetStepResult(step string, value cty.Value)
SetStepResult updates one step result.
func (*ScenarioState) Workdir ¶
func (s *ScenarioState) Workdir() string
Workdir returns the absolute per-scenario workspace directory. Relative save / file / exec paths resolve under it.