run

package
v0.0.0-...-9a3bad2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package run implements the clone/baseline/replace/retest loop for a single (upstream, dependent) pair.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResolveUpstream

func ResolveUpstream(ctx context.Context, workdir string, opts Options) (string, error)

ResolveUpstream returns an absolute path to the patched upstream source. If opts.UpstreamPath is set it's validated by manager detection and used as-is; otherwise opts.UpstreamRepo is cloned at opts.UpstreamRef into workdir/upstream. Exported so callers running many dependents can resolve once and pass the path to each Test.

Types

type Options

type Options struct {
	Module       string        // upstream package name as the dependent's manager knows it
	UpstreamRepo string        // git URL to clone the upstream from when UpstreamPath is empty
	UpstreamRef  string        // git ref to clone the upstream at; ignored if UpstreamPath is set
	UpstreamPath string        // local path to the patched upstream
	Dependent    string        // repo URL or local path
	DependentRef string        // optional ref to check out in the dependent
	Name         string        // display name for the dependent in reports; defaults to Dependent
	Workdir      string        // base directory for clones; temp dir if empty
	TestCmd      string        // override test command; defaults per ecosystem
	Timeout      time.Duration // per test run
	Keep         bool          // keep workdir on exit
	Stderr       io.Writer     // progress output
}

type Result

type Result struct {
	Module        string
	Dependent     string
	DependentPath string
	UpstreamPath  string
	Manager       string
	Narrowed      int // packages the test command was auto-narrowed to; 0 = ./...
	Baseline      TestRun
	Patched       TestRun
}

func Test

func Test(ctx context.Context, opts Options) (*Result, error)

Test runs the full loop for one dependent and returns a Result. The returned error is non-nil only for setup failures (clone, replace, detection); test failures are reported in the Result and don't cause an error here.

func (*Result) Failed

func (r *Result) Failed() bool

func (*Result) Markdown

func (r *Result) Markdown() string

func (*Result) Status

func (r *Result) Status() Status

Status classifies the run. Only "failed" should turn a CI check red: a dependent that was already broken is reported but not held against the upstream change.

type ResultEntry

type ResultEntry struct {
	Name     string
	Result   *Result
	SetupErr error
}

func (ResultEntry) Status

func (e ResultEntry) Status() Status

type Results

type Results []ResultEntry

Results aggregates one Result per dependent. SetupErr is set when Test returned an error before producing a Result (clone failed, replace failed, manager not detected); those count as errors in the summary but don't fail the overall run.

func (Results) AnyFailed

func (rs Results) AnyFailed() bool

func (Results) Count

func (rs Results) Count(s Status) int

func (Results) Markdown

func (rs Results) Markdown() string

Markdown returns a summary table followed by per-dependent detail for anything that didn't pass.

type Status

type Status string
const (
	StatusPassed         Status = "passed"
	StatusFailed         Status = "failed"
	StatusBrokenBaseline Status = "broken-baseline"
	StatusError          Status = "error"
)

type TestRun

type TestRun struct {
	Command  []string
	Output   string
	ExitCode int
	Duration time.Duration
	Err      error // non-nil only when the process failed to start
}

TestRun captures the outcome of one `go test ./...` invocation. Step 5 in the plan upgrades this to per-test diffing via -json; for now it's exit-code plus combined output.

func (TestRun) Passed

func (r TestRun) Passed() bool

Jump to

Keyboard shortcuts

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