graph

package
v0.0.0-...-ef92b72 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package graph builds and analyzes the dependency graph between test cases.

The graph builder inspects template references in test fields ({{ alias.path }}, {{ savedVar }}, {{ prev.body.id }}) and constructs a directed acyclic graph where edges represent "must run after" relationships.

After the graph is built, it is topologically sorted and grouped into waves: sets of tests that have no dependencies on each other and can run in parallel.

Responsibilities

  • Extract template references via regex
  • Match references to alias-defining tests
  • Build a directed graph of dependencies
  • Detect cycles and report them with the participating tests
  • Topologically sort with deterministic tie-breaking
  • Group into parallel waves
  • Compute SaveRequirements (which fields each producer must persist)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

type Builder struct{}

Builder constructs a dependency graph from a set of test files.

func New

func New() *Builder

New returns a new Builder. Builder is stateless and safe for concurrent use.

func (*Builder) Build

func (b *Builder) Build(files []*manifest.TestFile) (*Plan, error)

Build analyzes every test across the given files and produces a Plan with ordered waves, dependencies, and the per-producer save requirements.

Build returns an error on duplicate aliases, missing alias references in explicit `depends:`, or dependency cycles (returned as *CycleError).

Matrix expansion and load-test replication are deferred — see TODOs.

type CycleError

type CycleError struct {
	Cycle []*TestRef
}

CycleError indicates a dependency cycle. Cycle lists the tests involved.

func (*CycleError) Error

func (e *CycleError) Error() string

type Dependency

type Dependency struct {
	From  *TestRef
	To    *TestRef
	Type  DependencyType
	Alias string
	Paths []string
}

Dependency describes a "must run after" relationship.

type DependencyType

type DependencyType int

DependencyType classifies how a dependency was discovered.

const (
	DepTemplate DependencyType = iota
	DepExplicit
	DepPrev
)

type Plan

type Plan struct {
	Waves            []Wave
	Dependencies     []Dependency
	SaveRequirements map[string]SaveRequirement
}

Plan is the execution plan produced by the graph builder.

type Reference

type Reference struct {
	Name string
	Path string
}

Reference is a parsed template reference found in a test field.

type SaveRequirement

type SaveRequirement struct {
	Required  bool
	Paths     []string
	Consumers []string
}

SaveRequirement describes what a producer test must persist for its consumers.

type TestRef

type TestRef struct {
	File  *manifest.TestFile
	Test  *manifest.TestCase
	Mode  manifest.TestMode
	Index int // position within the file
}

TestRef points to a specific test within a specific file.

func (*TestRef) ID

func (r *TestRef) ID() string

ID returns a stable identifier for the test based on file path and index.

type Wave

type Wave struct {
	Index    int
	Parallel bool
	Tests    []*TestRef
}

Wave is a group of tests that can run in parallel (no dependencies between them).

Jump to

Keyboard shortcuts

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