coverage

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package coverage collects per-s-expression coverage data from executing Wile Scheme code. Each coverage entry corresponds to a unique SourceContext (file + start/end line/column), aggregated across all compiled NativeTemplates.

Known limitations:

  • Instructions synthesized by the peephole optimizer may drop their source attribution (see machine/peephole_test.go:540). Such PCs execute but produce no Entry.
  • Instructions with no source context (synthetic infrastructure ops) are skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteGoCover

func WriteGoCover(w io.Writer, c *Collector) error

WriteGoCover writes the collector's entries in Go cover v1 format (mode: set), excluding stdlib paths. The output is consumable by 'go tool cover -html -o report.html <file>'.

func WriteGoCoverIncludingStdlib

func WriteGoCoverIncludingStdlib(w io.Writer, c *Collector) error

WriteGoCoverIncludingStdlib is like WriteGoCover but includes entries from embedded stdlib files.

func WriteSummary

func WriteSummary(w io.Writer, c *Collector) error

WriteSummary writes a human-readable per-line coverage summary with a total footer. Each line emits:

<file>:<line>  <covered>/<total> covered  max_col_reached=<col>

max_col_reached is the maximum start column of any covered sexpr on that line, under the interpretation "how deep did we get." Honest under non-branching sequences like (begin a b c); approximate under branches — a high max_col_reached with low covered/total means execution skipped sexprs in the middle.

Stdlib paths are excluded.

func WriteSummaryIncludingStdlib

func WriteSummaryIncludingStdlib(w io.Writer, c *Collector) error

WriteSummaryIncludingStdlib is like WriteSummary but includes entries from embedded stdlib files.

Types

type Collector

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

Collector aggregates coverage data across a set of tracked templates. A zero Collector is not usable; construct with NewCollector.

func NewCollector

func NewCollector() *Collector

NewCollector returns a ready-to-use Collector.

func (*Collector) Entries

func (p *Collector) Entries() []Entry

Entries returns one Entry per unique SourceContext seen across all tracked templates. Entries are sorted lexicographically by (File, StartLine, StartCol, EndLine, EndCol). An s-expression is reported with Count=1 iff any instruction referring to its SourceContext executed (mode=set).

func (*Collector) Track

func (p *Collector) Track(tpl *machine.NativeTemplate)

Track enables coverage on a template and adds it to the collector's tracked set. Calling Track multiple times with the same template is a no-op (templates are deduplicated by pointer identity).

type Entry

type Entry struct {
	File      string
	StartLine int
	StartCol  int
	EndLine   int
	EndCol    int
	// Count is 0 if the s-expression did not execute, 1 if it did
	// (mode=set). Higher modes are a future extension.
	Count int
}

Entry is one covered (or not covered) s-expression.

Jump to

Keyboard shortcuts

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