report

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteGitHubAnnotations

func WriteGitHubAnnotations(w io.Writer, r *Report) error

WriteGitHubAnnotations writes one ::warning:: workflow command per LIVED mutant in r to w. The format is consumed by GitHub Actions and surfaces as inline annotations on the PR diff. See: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions

func WriteHTML

func WriteHTML(path string, mutants []mutator.Mutant, projectDir, frameworkVersion string) error

WriteHTML writes a self-contained interactive HTML mutation report at path. The output bundles the Stryker mutation-testing-elements web component and the Stryker v2 report JSON into a single file with no external assets — it renders in any browser, including offline (air-gapped CI artifacts).

frameworkVersion is recorded in the embedded report; pass the running gomutants version.

func WriteJSON

func WriteJSON(r *Report, path string) error

WriteJSON writes the report to a file.

func WriteStryker

func WriteStryker(path string, mutants []mutator.Mutant, projectDir, frameworkVersion string) error

WriteStryker writes a Stryker v2 mutation-testing report to path. mutants must reference real source files on disk (Mutant.File absolute paths) so the emitter can read source and resolve byte offsets to line/column positions.

frameworkVersion is recorded under .framework.version; pass the running gomutants version.

Types

type FileReport

type FileReport struct {
	FileName  string           `json:"file_name"`
	Mutations []MutationReport `json:"mutations"`
}

FileReport groups mutations by file.

type MutationReport

type MutationReport struct {
	ID          string `json:"id"`
	Type        string `json:"type"`
	Status      string `json:"status"`
	Line        int    `json:"line"`
	Column      int    `json:"column"`
	Original    string `json:"original,omitempty"`
	Replacement string `json:"replacement,omitempty"`
}

MutationReport is a single mutation entry.

ID is gomutants-specific (additive, ignored by gremlins consumers): a cross-run handle of the form "rel_file:anchor:TYPE#n" — see mutator.Mutant.StableID. It is stable against line shifts and edits to other functions, so reports from successive runs can be diffed entry by entry. It changes when the mutant's own function is renamed, or when a same-type mutation point is added or removed earlier in that function.

type Report

type Report struct {
	GoModule          string       `json:"go_module"`
	Files             []FileReport `json:"files"`
	TestEfficacy      float64      `json:"test_efficacy"`
	MutationsCoverage float64      `json:"mutations_coverage"`
	MutantsTotal      int          `json:"mutants_total"`
	MutantsKilled     int          `json:"mutants_killed"`
	MutantsLived      int          `json:"mutants_lived"`
	MutantsNotViable  int          `json:"mutants_not_viable"`
	MutantsNotCovered int          `json:"mutants_not_covered"`
	MutantsTimedOut   int          `json:"mutants_timed_out,omitempty"`
	MutantsInfraError int          `json:"mutants_infra_error,omitempty"`
	MutantsCached     int          `json:"mutants_cached,omitempty"`
	MutantsSuppressed int          `json:"mutants_suppressed,omitempty"`
	// MutantsSuppressedByCalls is the --exclude-calls share of
	// MutantsSuppressed, not an additional bucket. Set by the caller after
	// Generate, since only it knows the split.
	MutantsSuppressedByCalls int            `json:"mutants_suppressed_by_calls,omitempty"`
	MutantsEquivalent        int            `json:"mutants_equivalent,omitempty"`
	MutantsRechecked         int            `json:"mutants_rechecked,omitempty"`
	MutantsRecheckKilled     int            `json:"mutants_recheck_killed,omitempty"`
	ElapsedTime              float64        `json:"elapsed_time"`
	MutatorStatistics        map[string]int `json:"mutator_statistics"`
}

Report is the gremlins-compatible JSON report structure.

MutantsCached and MutantsSuppressed are gomutants-specific (additive, ignored by gremlins consumers). MutantsCached counts mutants whose status was sourced from the incremental-analysis cache. MutantsSuppressed counts mutants dropped by `// gomutants:disable*` directives or by --exclude-calls — these don't appear in Files[].Mutations and are excluded from MutantsTotal and from the TestEfficacy and MutationsCoverage denominators. MutantsSuppressedByCalls breaks out the --exclude-calls share of that total. MutantsEquivalent counts surviving mutants proven equivalent to the original by Trivial Compiler Equivalence (--detect-equivalent). They stay in MutantsTotal but count as neither KILLED nor LIVED, so they drop out of the TestEfficacy denominator — an equivalent mutant is not a test gap. MutantsInfraError counts mutants for which environmental resource or I/O failure prevented a verdict. They stay in MutantsTotal and mutation coverage, but count as neither KILLED nor LIVED for TestEfficacy. MutantsRechecked counts mutants their covering tests didn't kill that were then run against every test suite that can kill them, and MutantsRecheckKilled those of them that re-check killed: survivors the per-test coverage map would have reported, a sign of tests that depend on running after others.

func Generate

func Generate(mutants []mutator.Mutant, goModule string, elapsed time.Duration, suppressedCount int) *Report

Generate builds a Report from the list of mutants. suppressedCount is the number of mutants dropped before this point by `// gomutants:disable*` directives or by --exclude-calls — they are not in `mutants` and contribute to no count except `MutantsSuppressed`. Callers that know the split set MutantsSuppressedByCalls afterwards.

type Terminal

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

Terminal handles progress output to the terminal.

func NewTerminal

func NewTerminal(w io.Writer, total int, verbose, quiet bool) *Terminal

NewTerminal creates a terminal progress reporter. w counts as a TTY when it can Stat itself as a character device — an *os.File in production, or a test double that captures what a terminal would show.

func (*Terminal) FinishProgress added in v0.7.3

func (t *Terminal) FinishProgress()

FinishProgress ends the TTY progress-bar line with a newline, once. Call it after the last OnResult so later output starts on a fresh line; Summary calls it too, for runs that never reach that point.

func (*Terminal) Header

func (t *Terminal) Header(version string, target string, workers int, mutatorCount int)

Header prints the initial info banner.

func (*Terminal) Info

func (t *Terminal) Info(format string, args ...any)

Info prints one informational line, such as a report path. Like the phase lines it is silenced by quiet; the summary is not.

func (*Terminal) OnResult

func (t *Terminal) OnResult(m mutator.Mutant)

OnResult is the callback for each completed mutant.

func (*Terminal) Phase

func (t *Terminal) Phase(msg string)

Phase prints a phase status line.

func (*Terminal) PhaseDone

func (t *Terminal) PhaseDone(msg string)

PhaseDone completes a phase line.

func (*Terminal) RecheckHint added in v0.7.2

func (t *Terminal) RecheckHint(r *Report)

RecheckHint tells the reader how to re-check one LIVED mutant after adding a test, without a full rerun. It names the flags to add to the reader's own command rather than printing one: only that command carries every flag the verdict depends on (--integration, --config, --only, ...), quoted for their shell. The flags must go before the packages, where flag parsing stops. Prints nothing when no mutant lived.

func (*Terminal) StartHeartbeat

func (t *Terminal) StartHeartbeat()

StartHeartbeat begins painting an idle progress line every heartbeatInterval so the user sees forward motion while workers compile the first per-package test binary (no OnResult fires until the first mutant completes — a 10-60s silence on a non-trivial project). OnResult auto-stops the heartbeat when the first result arrives; callers should still defer StopHeartbeat in case zero mutants ever complete (e.g., upstream cancel, or all-cached run).

Second call is a no-op: hbStopOnce fires on the first StopHeartbeat, so a re-spawned goroutine could never be stopped — the hbStop != nil guard prevents the leak.

No-op when quiet, verbose, off-TTY, or total == 0 — those modes either suppress output entirely or print line-per-mutant, where a \r-based spinner would corrupt the transcript.

func (*Terminal) StopHeartbeat

func (t *Terminal) StopHeartbeat()

StopHeartbeat halts the heartbeat goroutine (if any) and clears its trailing "(compiling)" suffix from the line so the next progress-bar paint starts from a clean slate. Idempotent via sync.Once; safe to call from any goroutine and multiple times.

func (*Terminal) Summary

func (t *Terminal) Summary(r *Report)

Summary prints the final summary.

Jump to

Keyboard shortcuts

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