Documentation
¶
Overview ¶
Package test is the StageFreight test subsystem: it resolves declared/synthesized test suites into native commands, runs them, and models the verdict. It owns suite resolution, command construction, execution, and aggregation; the lifecycle (audition adapter) consumes only the normalized verdict.
Index ¶
Constants ¶
const ( StatusPassed = "passed" StatusFailed = "failed" StatusSkipped = "skipped" )
Suite status values.
Variables ¶
This section is empty.
Functions ¶
func Verify ¶
func Verify(ctx context.Context, cfg *config.Config, rootDir string, w io.Writer, intent Intent) (bool, error)
Verify resolves the configured suites, runs them, and renders the result under the given intent. It returns whether all GATING (non-advisory) suites passed.
This is the single behavioral-verification entry point every caller shares — the audition correctness gate (IntentCorrectness: "is the committed tree healthy?") and dependency mutation re-verification (IntentDepReverify: "did the mutation preserve health?"). One execution model, one renderer, one gate, one suite identity — deps never shells its own `go test`. No suites resolve → passed=true.
Types ¶
type Intent ¶
type Intent int
Intent distinguishes WHY the suites ran, so the canonical render surface reads correctly for each caller. The dependency re-verification run is NOT "the test stage again" — it validates a proposed graph mutation — so it gets its own header.
type PackageResult ¶
type PackageResult struct {
ImportPath string // github.com/PrPlanIT/StageFreight/src/commit
Rel string // module-relative: src/commit
Synopsis string // package doc synopsis (go list .Doc); may be empty
Status string // StatusPassed | StatusFailed | StatusSkipped (no test files)
Duration time.Duration
Tests int // top-level tests run
Coverage float64 // statement coverage %; <0 means "not measured"
Failures []TestFailure // leaf failures (with output), when Status==failed
}
PackageResult is one package's outcome, parsed from `go test -json` — the StageFreight-native presentation derived from go's transport stream. `Rel` is the module-relative path (preserves WHERE it ran without the long import prefix); `Synopsis` is the package doc-comment one-liner (what it IS, for non-test-writers).
type ResolvedSuite ¶
type ResolvedSuite struct {
ID string
Tool config.TestTool
Gate config.Gate
Argv []string
Dir string
Coverage bool // coverage requested (go: -cover; rust: cargo llvm-cov)
CoverageMin float64 // gate threshold %; 0 = none
Synthesized bool
Provenance string // human note (synthesized suites): why / from which build
}
ResolvedSuite is a suite ready to execute: a concrete argv + working directory.
func Resolve ¶
func Resolve(cfg *config.Config, rootDir string) ([]ResolvedSuite, error)
Resolve turns the test config (+ builds) into executable suites. When the operator declared no suites and auto-synthesis is on, it derives one default suite per testable (go/rust binary) build, each with a provenance-stamped id.
type SuiteResult ¶
type SuiteResult struct {
ID string
Tool config.TestTool
Gate config.Gate
Status string
Duration time.Duration
Packages []PackageResult // per-package detail (Go suites, parsed from -json)
Coverage float64 // statement-weighted suite total %; <0 = not measured
CoverageMin float64 // gate threshold %; 0 = none
Output string // captured stderr (build errors etc.)
Err error // execution error (process failure / non-zero exit)
}
SuiteResult is one suite's outcome — individually addressable for logs and future narrate/reporting. Coverage/Artifacts are reserved (not populated in v1).
type TestFailure ¶
TestFailure is a single failing (leaf) test and its captured output.
type TestResult ¶
type TestResult struct {
Suites []SuiteResult
}
TestResult aggregates per-suite outcomes.
func RunRender ¶
func RunRender(ctx context.Context, suites []ResolvedSuite, rootDir string, desired map[string]config.ToolConstraint, w io.Writer, intent Intent) *TestResult
RunRender realizes substrate, runs the suites, and renders ONE canonical section that everything streams INTO: an explained substrate note (what native tools were provisioned and WHY), each package's row as it finishes (no stranded output), failures expanded inline, then the coverage summary with the no-test packages collapsed to one callout. Derived from `go test -json`, never raw transport. The single presentation surface for the audition gate, deps re-verification, and the `stagefreight test` CLI. Returns the verdict.
func (TestResult) Failed ¶
func (r TestResult) Failed() bool
Failed reports whether any suite failed at all (advisory included), for reporting.
func (TestResult) FailedNonAdvisory ¶
func (r TestResult) FailedNonAdvisory() bool
FailedNonAdvisory reports whether any suite with a non-advisory gate failed. This is v1's entire gate verdict: the audition adapter fails the audition job (→ the cistate artifact is withheld → perform + downstream halt) when true.