Documentation
¶
Overview ¶
Package mutate implements mutation testing stages for chunk mutate.
Index ¶
Constants ¶
const ( OpConditionalsBoundary = "CONDITIONALS_BOUNDARY" OpConditionalsNegation = "CONDITIONALS_NEGATION" OpArithmeticBase = "ARITHMETIC_BASE" OpIncrementDecrement = "INCREMENT_DECREMENT" OpInvertAssignments = "INVERT_ASSIGNMENTS" OpInvertBitwise = "INVERT_BITWISE" OpInvertBitwiseAssignments = "INVERT_BITWISE_ASSIGNMENTS" )
Gremlins operator names.
const DefaultTestTimeout = 3 * time.Minute
DefaultTestTimeout caps how long a single mutation's test run may stream output before the mutation is marked as an infrastructure failure.
Variables ¶
This section is empty.
Functions ¶
func DetectedStack ¶
func DetectedStack(dir string, cfg *config.ProjectConfig) string
DetectedStack is exported for use in the cmd layer.
Types ¶
type GoEnumerator ¶
type GoEnumerator struct {
// Paths to search: package dirs, files, or ./... patterns.
// Defaults to the full workDir tree when empty.
Paths []string
}
GoEnumerator walks Go source files and enumerates mutation candidates using the built-in operator set. No external tools required.
func EnumeratorFor ¶
func EnumeratorFor(dir string, cfg *config.ProjectConfig) (*GoEnumerator, error)
EnumeratorFor returns the GoEnumerator for the project. It consults cfg.Environment.Stack first, then falls back to file pattern detection in dir.
type Mutation ¶
type Mutation struct {
ID string `json:"id"`
File string `json:"file"`
Line int `json:"line"`
Col int `json:"col"`
Operator string `json:"operator"`
Status string `json:"status"` // RUNNABLE or NOT COVERED
Before string `json:"before"` // original token, e.g. "<"
After string `json:"after"` // mutated token, e.g. "<="
}
Mutation is a single candidate change to production code.
type Result ¶
type Result struct {
Mutation Mutation
Killed bool // true if the test suite caught the mutation
Output string // combined test output (may be truncated)
Error string // non-empty if setup failed (patch apply, reset, etc.)
}
Result is the outcome of running a single mutation against the test suite.
func Run ¶
func Run( ctx context.Context, pool *sidecar.Pool, mutations []Mutation, workDir, testCmd string, testTimeout time.Duration, status iostream.StatusFunc, ) ([]Result, error)
Run computes a tiny per-mutation patch for each candidate, then dispatches test runs to the sidecar pool in parallel.