Help us shape the future of Go! Take the 2026 Go Developer Survey

testselection

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package testselection recommends bounded verification commands from static repository evidence. Recommendations neither execute tests nor prove coverage.

Index

Constants

View Source
const (
	// ModeTargeted runs plan-declared commands and tests with a direct static
	// relationship to the change (changed tests, import or contract impact,
	// Go package companions, cross-component integration suites).
	ModeTargeted = "targeted"
	// ModeBalanced adds conservative package-root fallbacks for changes whose
	// direct test relationship was not established. "recommended" is an alias.
	ModeBalanced = "balanced"
	// ModeFull runs one discovered whole-suite command per framework and
	// package root, plus plan-declared commands.
	ModeFull = "full"

	TierRequired = "required"
	TierOptional = "optional"

	// DefaultMaxCommands bounds one verification run after grouping.
	DefaultMaxCommands = 16
)

Selection modes. None of them implies complete behavioral coverage.

View Source
const MaxFileBytes int64 = 1 << 20
View Source
const MaxFiles = 10000
View Source
const MaxTotalBytes int64 = 32 << 20

Variables

This section is empty.

Functions

func Documentation added in v0.2.0

func Documentation(p string) bool

Documentation reports a documentation or image file, for which selection proposes no test. It describes selection only: it does not establish that no test reads the file.

func NormalizeMode

func NormalizeMode(mode string) (string, error)

NormalizeMode maps accepted spellings to a mode, or reports an error.

Types

type Command

type Command struct {
	ID              string   `json:"id"`
	Command         []string `json:"command"`
	CWD             string   `json:"cwd"`
	Framework       string   `json:"framework"`
	TestFiles       []string `json:"test_files"`
	Affected        []string `json:"affected"`
	EvidenceReasons []Reason `json:"evidence_reasons"`
	Priority        int      `json:"priority"`
	ToolAvailable   bool     `json:"tool_available"`
	// Tier is required or optional; set by Plan, empty in raw proposals.
	Tier string `json:"tier,omitempty"`
	// GroupedFrom lists the per-file candidate IDs merged into this command.
	GroupedFrom []string `json:"grouped_from,omitempty"`
	// JUnit is the CWD-relative report file or TEST-*.xml directory the
	// runner writes, for runners whose output carries no test counts.
	JUnit string `json:"junit,omitempty"`
}

type Inventory

type Inventory struct {
	Revision    string             `json:"revision"`
	Tests       []Test             `json:"tests"`
	Diagnostics []model.Diagnostic `json:"diagnostics"`
	Manifests   []string           `json:"manifests"`
}

func Discover

func Discover(ctx context.Context, root, ref string) (Inventory, error)

Discover reads working-tree or immutable commit files without importing code, invoking package managers, or evaluating repository scripts/configuration.

func DiscoverProvider

func DiscoverProvider(ctx context.Context, p indexer.Provider, revision string) (Inventory, error)

DiscoverProvider shares identical discovery logic for source-state providers.

type Omission

type Omission struct {
	ID          string   `json:"id"`
	Command     []string `json:"command"`
	CWD         string   `json:"cwd"`
	TestFiles   []string `json:"test_files"`
	Tier        string   `json:"tier"`
	Reason      string   `json:"reason"`
	Explanation string   `json:"explanation"`
}

Omission records a candidate command that was not selected or not executed.

type Options

type Options struct {
	Plan  *planning.Plan
	Limit int
	// ToolAvailable overrides PATH probing for deterministic tests or a known environment.
	ToolAvailable func(string) bool
}

type Proposal

type Proposal struct {
	Omitted     []Omission   `json:"omitted,omitempty"`
	Status      model.Status `json:"status"`
	Commands    []Command    `json:"commands"`
	Inventory   Inventory    `json:"inventory"`
	Limitations []string     `json:"limitations"`
}

func Recommend

func Recommend(ctx context.Context, root, ref string, snapshot model.Snapshot, changed []string, plan *planning.Plan) (Proposal, error)

func Select

func Select(inv Inventory, snapshot model.Snapshot, changed []string, o Options) (Proposal, error)

Select ranks declared intent and inferred impact. All commands remain proposals: static reachability does not establish complete behavioral coverage.

type Reason

type Reason struct {
	Code         string             `json:"code"`
	Explanation  string             `json:"explanation"`
	Evidence     model.Evidence     `json:"evidence"`
	Locations    []model.Provenance `json:"locations,omitempty"`
	RelatedFiles []string           `json:"related_files,omitempty"`
}

type Runner added in v0.2.0

type Runner struct {
	Framework   string `json:"framework"`
	Program     string `json:"program"`
	Tests       int    `json:"tests"`
	Unsupported int    `json:"unsupported"`
}

Runner summarizes the discovered tests of one framework and the program their selected commands would start. Program is empty when no command is safely known for some of those tests.

func Runners added in v0.2.0

func Runners(inv Inventory) []Runner

Runners groups an inventory by framework and program, in a stable order. It describes discovered tests only; it does not check availability.

type Selection

type Selection struct {
	Mode        string     `json:"mode"`
	MaxCommands int        `json:"max_commands"`
	Commands    []Command  `json:"commands"`
	Omitted     []Omission `json:"omitted"`
	Uncovered   []string   `json:"uncovered_changes"`
	Blocking    []string   `json:"blocking"`
	Candidates  int        `json:"candidate_commands"`
	TestFiles   int        `json:"selected_test_files"`
	Inventory   int        `json:"inventory_test_files"`
	Explanation string     `json:"explanation"`
}

Selection is a bounded, ordered execution plan derived from a proposal. Blocking lists reasons the selection cannot satisfy required verification; a gate must not pass on a selection with blocking reasons.

func Plan

func Plan(p Proposal, changed []string, mode string, maxCommands int) (Selection, error)

Plan derives a bounded execution plan. It never drops a required command silently: commands beyond the budget are listed as omitted and blocking.

type Test

type Test struct {
	ID          string           `json:"id"`
	Path        string           `json:"path"`
	Framework   string           `json:"framework"`
	PackageRoot string           `json:"package_root"`
	Evidence    model.Provenance `json:"evidence"`
	// contains filtered or unexported fields
}

Test is a conventional test file, not a compiler-validated executable case.

Jump to

Keyboard shortcuts

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