Help us shape the future of Go! Take the 2026 Go Developer Survey

conformance

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package conformance checks a peer against SPEC.md. The runner is a scripted peer with a key of its own: it connects to the peer under test (or listens for it), drives each scenario over the wire, checks every line it receives against the JSON Schema, and reports what the peer did.

It is what `awp conform` runs. The reference implementation passes it in its own tests; scripts/conformance.sh runs it against the Python peer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	OK   bool   `json:"ok"`
	What string `json:"what"`
}

Check is one thing a scenario looked at.

type Options

type Options struct {
	// Addr is the peer's address. The runner dials it once per scenario.
	Addr string
	// Listen is an address (tcp:host:port or unix:/path) to listen on
	// instead: the peer dials the runner, and the scenarios that fit one
	// connection run in turn on it. Solo scenarios are skipped.
	Listen string
	// Run is a shell command to start once the runner listens, with
	// {addr} replaced by the listening address; it is killed at the end.
	Run string
	// Only names the scenarios to run; nil runs all of them.
	Only []string
	// Timeout bounds each wait for the peer; 15 seconds by default.
	Timeout time.Duration
	// Name is the runner's hello name; "awp-conform" by default.
	Name string
	// Trace receives every line sent (dir "out") and received ("in").
	Trace func(dir string, line []byte)
	// Logf receives progress; nil discards it.
	Logf func(format string, args ...any)
}

Options say which peer to check and how.

type Peer

type Peer struct {
	Key   string   `json:"key"`
	Name  string   `json:"name,omitempty"`
	About string   `json:"about,omitempty"`
	V     int      `json:"v"`
	Caps  []string `json:"caps,omitempty"`
}

Peer is what the peer said about itself in hello.

type Report

type Report struct {
	Mode     string        `json:"mode"` // connect or listen
	Addr     string        `json:"addr"`
	Peer     *Peer         `json:"peer,omitempty"`
	Results  []Result      `json:"results"`
	Passed   int           `json:"passed"`
	Failed   int           `json:"failed"`
	Skipped  int           `json:"skipped"`
	Duration time.Duration `json:"duration"`
}

Report is the outcome of a run.

func Run

func Run(ctx context.Context, o Options) (*Report, error)

Run checks the peer and returns the report. The error is about the run itself (a bad address, no connection); scenario failures are in the report.

type Result

type Result struct {
	Name    string  `json:"name"`
	Section string  `json:"section"`
	Doc     string  `json:"doc"`
	Status  string  `json:"status"` // pass, fail or skip
	Reason  string  `json:"reason,omitempty"`
	Checks  []Check `json:"checks,omitempty"`
	Lines   int     `json:"lines"` // lines received from the peer
}

Result is the outcome of one scenario.

type Scenario

type Scenario struct {
	Name    string
	Section string // of SPEC.md
	Doc     string
	// Solo scenarios break the handshake or the connection, so they need
	// a connection of their own; in listen mode they are skipped. The
	// others run after a completed handshake.
	Solo bool
	// Handshake marks the scenario that drives the handshake itself: it
	// runs first on a connection.
	Handshake bool
	// Needs is a hello cap the peer must list, or the scenario is skipped.
	Needs string
	// contains filtered or unexported fields
}

Scenario is one scripted exchange with the peer.

func Scenarios

func Scenarios() []Scenario

Scenarios lists every scenario, in the order they run.

Jump to

Keyboard shortcuts

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