baseline

package
v2.7.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package baseline tracks known-surviving mutants so CI fails only on new regressions, not on pre-existing escapes that the team has accepted.

Usage:

First run:  --update-baseline  (writes current escaped set, exits 0)
CI:         baseline file committed; new runs fail only on NEW escapes

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MutantID

func MutantID(relFile, mutatorName, diff string) string

MutantID returns a stable identifier for a mutant. It hashes the relative file path, mutator name, and the actual changed lines from the diff — deliberately excluding line numbers so the ID survives refactors that only shift surrounding code.

func Write

func Write(path string, escaped []models.Mutant, moduleRoot string) error

Write serialises the escaped mutants to the baseline file. moduleRoot is used to make file paths relative and portable.

Types

type Entry

type Entry struct {
	ID      string `json:"id"`
	File    string `json:"file"`
	Mutator string `json:"mutator"`
	Line    int64  `json:"line"`
}

Entry describes one known-surviving mutant.

type File

type File struct {
	Version int     `json:"version"`
	Mutants []Entry `json:"mutants"`
}

File is the on-disk baseline format.

func Load

func Load(path string) (*File, error)

Load reads the baseline file. Returns (nil, nil) when the file does not exist — callers treat this as "no baseline active" and skip the check entirely.

func (*File) IDSet

func (f *File) IDSet() map[string]struct{}

IDSet returns the set of known mutant IDs for fast O(1) lookup.

func (*File) NewEscapes

func (f *File) NewEscapes(escaped []models.Mutant, moduleRoot string) []models.Mutant

NewEscapes returns mutants from escaped that are not recorded in this baseline. When f is nil (no baseline loaded), all mutants are considered new.

Jump to

Keyboard shortcuts

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