Documentation
¶
Overview ¶
Package runner discovers rehearse scenario files, executes their step blocks through the block-executor registry, and renders the run report (REQ: scenario-discovery, REQ: scenario-shape, REQ: run-report).
Index ¶
- Constants
- Variables
- func CountFailed(reports []ScenarioReport) int
- func Discover(paths []string, cwd string) ([]string, error)
- func GitProvenance(dir string) (sha string, dirty bool)
- func RenderHuman(w io.Writer, reports []ScenarioReport)
- func WriteReport(path string, runnerVersion string, startedAt time.Time, ...) error
- type Bag
- type RunReport
- type ScenarioReport
- type StepReport
Constants ¶
const ( StatusPass = "pass" StatusFail = "fail" StatusSkipped = "skipped" StatusNoSteps = "no-steps" )
Scenario statuses (REQ: scenario-shape, REQ: run-report).
const StepStatusSkipped = "skipped-after-failure"
StepStatusSkipped marks steps after the first failing step (REQ: scenario-shape).
Variables ¶
var ( // ExecCommandFn is the test seam for git invocations: it runs name with // args in dir and returns stdout. Exported so CLI-layer tests can control // git provenance output without touching the filesystem. // Feature: cli/rehearse/evidence (REQ: report-provenance) ExecCommandFn = execCommandOutput )
Test seams — package-level vars wrapping external functions. Production code calls these vars; tests replace them via t.Cleanup.
var NowFn = func() time.Time { return time.Now() }
NowFn is the test seam for time.Now. The CLI calls this to capture the run start time before dispatching to Run, so tests can control started_at. Feature: cli/rehearse/evidence (REQ: report-provenance)
Functions ¶
func CountFailed ¶
func CountFailed(reports []ScenarioReport) int
CountFailed returns how many scenarios failed (drives exit code 1, REQ: run-report).
func Discover ¶
Discover resolves the run's scenario files (REQ: scenario-discovery). Each path may be a file, a directory (scanned recursively for *.md, excluding README.md), or a glob. With no paths, it defaults to every scenario under spec/features/**/_tests/ of the SpecScore repo enclosing cwd. Explicit paths need no specscore.yaml (standalone mode). Zero discovered scenarios is a config error (exit 2), not an empty pass.
func GitProvenance ¶
GitProvenance collects HEAD SHA and dirty flag from the working tree at dir. Outside a git work tree (or when git is unavailable) it returns empty SHA and dirty=false — provenance is honest, never invented. Feature: cli/rehearse/evidence (REQ: report-provenance)
func RenderHuman ¶
func RenderHuman(w io.Writer, reports []ScenarioReport)
RenderHuman writes the human report: one line per scenario — status, file path, Verifies AC ids, duration — plus a totals line (REQ: run-report). Failing scenarios additionally get their failure detail and captured step output as indented diagnostic lines (REQ: bash-block).
func WriteReport ¶
func WriteReport(path string, runnerVersion string, startedAt time.Time, reports []ScenarioReport, dir string) error
WriteReport persists the run report envelope to path, creating parent directories as needed. The scenarios' file paths are made repo-root-relative when dir is inside a git work tree (the stdout report keeps its paths as-is).
Feature: cli/rehearse/evidence (REQ: report-out, REQ: report-provenance)
Types ¶
type Bag ¶
type Bag struct {
// contains filtered or unexported fields
}
Bag is one scenario run's context bag (REQ: context-bag): an ordered map of string variables. Steps feed it via their StepResult captures; consumption is per block class — bash/sql/dtql get {{name}} textual interpolation before dispatch, hurl-derived blocks receive the ordered Snapshot through StepCtx.Vars and hand it to Hurl as --variable flags.
func (*Bag) Interpolate ¶
Interpolate textually replaces every {{name}} placeholder with the bag's value for name. An unknown variable is an error naming it — the step fails instead of running with a literal placeholder (REQ: context-bag).
func (*Bag) Map ¶
Map returns a copy of the bag's final state for the JSON report (REQ: run-report). Never nil.
type RunReport ¶
type RunReport struct {
RunnerVersion string `json:"runner_version"`
GitSHA string `json:"git_sha"`
GitDirty bool `json:"git_dirty"`
StartedAt string `json:"started_at"`
Scenarios []ScenarioReport `json:"scenarios"`
}
RunReport is the persisted report envelope written by --report-out. It carries run provenance alongside the scenario results. Feature: cli/rehearse/evidence (REQ: report-provenance)
type ScenarioReport ¶
type ScenarioReport struct {
File string `json:"file"`
Status string `json:"status"`
Verifies []string `json:"verifies"`
DurationMS int64 `json:"duration_ms"`
Bag map[string]string `json:"bag"`
Steps []StepReport `json:"steps"`
// Detail carries scenario-level failure detail (e.g. a parse error).
Detail string `json:"detail,omitempty"`
// FilterStatus is "match" or "skip" when --filter is active; omitted otherwise.
// Feature: cli/rehearse/run-filter (REQ: filter-output-labels)
FilterStatus string `json:"filter_status,omitempty"`
// Expect is "fail" when the scenario declared `**Expect:** fail`; omitted for
// the default. A reported "pass" with Expect=="fail" is a correctly-failing
// negative scenario. Feature: cli/rehearse/expected-fail (REQ: expect-in-report)
Expect string `json:"expect,omitempty"`
// Case is the `### When …` branch label when this report is one case of a
// nested scenario suite; omitted for a flat scenario. Feature:
// cli/rehearse/nested-suites.
Case string `json:"case,omitempty"`
}
ScenarioReport is one scenario's outcome in the JSON report (REQ: run-report).