testing

package
v0.0.0-...-3cc2fd5 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusValid        = "valid"
	StatusInvalid      = "invalid"
	StatusCompileError = "error"
)

Variables

This section is empty.

Functions

func ApplySchemataInMemory

func ApplySchemataInMemory(src []byte, filePath string, fset *token.FileSet, fileMutants []*Mutant) (*ast.File, error)

ApplySchemataInMemory applies schemata to a fresh parse of src and returns the mutated AST without any disk I/O. Used by preflight type-checking.

func ApplySchemataToAST

func ApplySchemataToAST(fileAST *ast.File, fset *token.FileSet, filePath string, src []byte, fileMutants []*Mutant) (map[int]PositionMapping, error)

func ApplySchemataToFile

func ApplySchemataToFile(filePath string, fileMutants []*Mutant) (map[int]PositionMapping, error)

func CopyDir

func CopyDir(src, dst string) error

func FindGoModDir

func FindGoModDir(dir string) string

func GetTotalMutants

func GetTotalMutants() int

func InjectSchemataHelpers

func InjectSchemataHelpers(fileToMutants map[string][]*Mutant, log *logger.Logger) error

func LogPreflightResults

func LogPreflightResults(log *logger.Logger, totalMutants int, results []PreflightResult, validCount int)

LogPreflightResults prints a summary of filtered mutants.

func MakeSelfContained

func MakeSelfContained(tempDir string) error

func ResolveCache

func ResolveCache(mutants []Mutant, baseDir string, c *cache.Cache) (toRun []int, fileHashes map[string]string, err error)

func RewriteImports

func RewriteImports(_ string) error

func RunPreflight

func RunPreflight(mutants []Mutant, log *logger.Logger) ([]Mutant, []PreflightResult)

RunPreflight validates all mutants with three-level filtering.

Level 1 — fast static checks (nil node/file, obviously unsafe)
Level 2 — schemata AST integrity (can format.Node produce output?)
Level 3 — go/types type-check of the schemata-transformed code

Level 3 catches type errors (wrong inferred types, scope leaks from := wrapping, blanked imports) before the workspace build step.

func SaveCache

func SaveCache(mutants []Mutant, baseDir string, c *cache.Cache, fileHashes map[string]string)

func SetGoVersion

func SetGoVersion(version string)

SetGoVersion allows overriding the detected Go version (for testing or config).

func UniqueErrorLines

func UniqueErrorLines(output string, skipPrefix string) []string

Types

type CompilerError

type CompilerError struct {
	File    string
	Line    int
	Col     int
	Message string
}

func ParseCompilerErrors

func ParseCompilerErrors(output string) []CompilerError

type ModuleWorkspace

type ModuleWorkspace struct {
	TempDir string
	// contains filtered or unexported fields
}

func NewModuleWorkspace

func NewModuleWorkspace() (*ModuleWorkspace, error)

func (*ModuleWorkspace) Cleanup

func (w *ModuleWorkspace) Cleanup()

type Mutant

type Mutant struct {
	ID           int
	Site         engine.Site
	Operator     mutator.Operator
	TempDir      string
	TempLine     int
	TempCol      int
	Status       string
	Error        error
	KilledBy     string
	KillDuration time.Duration
	KillOutput   string
	ErrorReason  string
}

func GenerateAndRunSchemata

func GenerateAndRunSchemata(ctx context.Context, sites []engine.Site, operators []mutator.Operator, allOps []mutator.Operator, baseDir string, projectRoot string, dirRules []config.DirOperatorRule, resolver *subconfig.Resolver, concurrent int, cache *cache.Cache, tests []string, testPaths []string, log *logger.Logger, progbar bool, unitTestsEnabled bool, externalCfg config.ExternalSuitesConfig, cfg *config.Config) ([]Mutant, error)

func GenerateMutants

func GenerateMutants(sites []engine.Site, operators []mutator.Operator, allOps []mutator.Operator, projectRoot string, dirRules []config.DirOperatorRule, resolver *subconfig.Resolver, log *logger.Logger) []Mutant

type MutantSite

type MutantSite struct {
	File string
	Line int
	Col  int
}

type PositionMapping

type PositionMapping struct {
	OriginalLine int
	OriginalCol  int
	TempLine     int
	TempCol      int
}

type PreflightResult

type PreflightResult struct {
	MutantID    int
	Status      string
	Error       error
	ErrorReason string
}

type ProgressTracker

type ProgressTracker struct {
	// contains filtered or unexported fields
}

func NewProgressTracker

func NewProgressTracker(total int) *ProgressTracker

func (*ProgressTracker) Finish

func (p *ProgressTracker) Finish()

func (*ProgressTracker) Record

func (p *ProgressTracker) Record()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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