gorunner

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 21 Imported by: 0

Documentation

Overview

Package gorunner executes one bounded, explicit Go test plan.

Index

Constants

View Source
const (
	CoverageModeSet    = coverprofile.ModeSet
	CoverageModeCount  = coverprofile.ModeCount
	CoverageModeAtomic = coverprofile.ModeAtomic
)
View Source
const (
	MaxOutputBytes   = int64(8 << 20)
	MaxCoverageBytes = coverprofile.MaxBytes
	// MaxPackages leaves room for the executable and four frozen go arguments
	// within the 4,096-element argv bound.
	MaxPackages   = 4_091
	MaxArgvBytes  = 4 << 20
	MaxEnvEntries = 256
	MaxEnvBytes   = 1 << 20
	MaxRunTime    = 30 * time.Minute
	MaxPipeWait   = 2 * time.Second
)

Variables

View Source
var (
	ErrInvalidPlan         = errors.New("gorunner: invalid plan")
	ErrUnsupportedPlatform = errors.New("gorunner: unsupported platform")
	ErrStart               = errors.New("gorunner: start failed")
	ErrWait                = errors.New("gorunner: wait failed")
	ErrPipe                = errors.New("gorunner: pipe drain failed")
	ErrPipeWait            = errors.New("gorunner: pipe drain timed out")
	ErrContainment         = errors.New("gorunner: process-group cleanup failed")
)

Functions

func ParseCoverProfile added in v0.7.0

func ParseCoverProfile(raw []byte) (CoverageMode, []CoverageBlock, error)

ParseCoverProfile parses one local coverprofile without a source mapping (internal/cem/coverprofile.Parse).

Types

type Containment

type Containment string
const (
	ContainmentProcessGroupBestEffort Containment = "PROCESS_GROUP_BEST_EFFORT"
	ContainmentUnsupported            Containment = "UNSUPPORTED"
)

type CoverageBlock added in v0.7.0

type CoverageBlock = coverprofile.Block

CoverageBlock is one parsed coverprofile block line.

func ParseCoverageBlockLine added in v0.7.0

func ParseCoverageBlockLine(line string, mode CoverageMode) (CoverageBlock, error)

ParseCoverageBlockLine parses one coverprofile block line under mode with the grammar the runner applies to its own captured profile (internal/cem/coverprofile.ParseBlockLine).

type CoverageCompleteness

type CoverageCompleteness string
const (
	CoverageAbsent   CoverageCompleteness = "ABSENT"
	CoverageComplete CoverageCompleteness = "COMPLETE"
	CoveragePartial  CoverageCompleteness = "PARTIAL"
	CoverageRejected CoverageCompleteness = "REJECTED"
)

type CoverageMode

type CoverageMode = coverprofile.Mode

CoverageMode is the coverprofile mode; the grammar lives in internal/cem/coverprofile so the CEM seams need not import this runner.

type CoverageObservation

type CoverageObservation struct {
	ArtifactSHA256 string
	Completeness   CoverageCompleteness
	Mode           string
	Packages       []string
	RawRootSHA256  string
}

type CoveragePackage

type CoveragePackage struct {
	ImportPath string
	Files      []CoverageSourceFile
}

type CoverageRequest

type CoverageRequest struct {
	Directory      string
	ProfilePath    string
	RepositoryRoot string
	Mode           CoverageMode
	Packages       []CoveragePackage
}

type CoverageSourceFile

type CoverageSourceFile struct {
	ProfilePath string
	SourcePath  string
	RawSHA256   string
}

type EnvironmentVariable

type EnvironmentVariable struct {
	Name  string
	Value string
}

type Plan

type Plan struct {
	// GoExecutable and WorkingDirectory must be clean absolute paths whose final
	// components are not symlinks. Mandatory parent-component, source, toolchain,
	// and environment identity checks belong to the coordinator immediately
	// before and after Run; Run exposes no potentially unbounded callbacks.
	GoExecutable     string
	WorkingDirectory string
	Environment      []EnvironmentVariable
	Packages         []string
	OutputLimitBytes int64
	// RetainOutput keeps at most OutputLimitBytes across both Result Data fields.
	// Data is transient caller-owned output and is nil when RetainOutput is false.
	// Bounded retention deliberately replaces arbitrary streaming callbacks: an
	// uncooperative callback could defeat the hard return bound.
	RetainOutput bool
	Timeout      time.Duration
	// Coverage is an opt-in combined-run coverage request. Nil preserves the
	// exact non-coverage invocation and result.
	Coverage *CoverageRequest
}

type Result

type Result struct {
	Argv                []string
	Cancelled           bool
	Containment         Containment
	Duration            time.Duration
	ExitCode            int
	Exited              bool
	OutputLimitExceeded bool
	PipeWaitExpired     bool
	ProcessCleanupDone  bool
	Started             bool
	Stderr              StreamResult
	Stdout              StreamResult
	TimedOut            bool
	Coverage            CoverageObservation
}

func Run

func Run(ctx context.Context, plan Plan) (result Result, runErr error)

type StreamResult

type StreamResult struct {
	Bytes uint64
	// Data is a transient bounded copy and is nil unless Plan.RetainOutput is true.
	Data      []byte
	Drained   bool
	RawSHA256 string
}

Jump to

Keyboard shortcuts

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