testverbhelp

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package testverbhelp is the per-tool check of the verb-help rule (the CLI style's rule (b), #4505; internal/nsprint/verbflag is the one seam that implements it): `<tool> <verb> -h` and `--help` print that verb's help on stdout and exit 0, with nothing on stderr, no file written and no dial. The check opens no socket: it is a unit-tier check.

Each tool's test names its verbs and, for each, the flags that would point the verb at a place: a path flag gets {dir}/..., a store address gets {addr}. They are given BEFORE -h, so the parser has taken them when it meets -h, and the check then holds that nothing was created under {dir}. {addr} is RefusedAddr, a loopback port nothing listens on: the check owns no socket, and a verb that dials before it answers -h meets a refusal and fails the exit, stderr or budget clause.

Index

Constants

View Source
const Budget = 50 * time.Millisecond

Budget is how long help may take. Help is a print; anything that took longer than this dialed, waited or walked something.

View Source
const RefusedAddr = "127.0.0.1:1"

RefusedAddr is what {addr} becomes: loopback port 1, where nothing listens, so a dial is refused at once and the check needs no listener of its own.

Variables

This section is empty.

Functions

func Check

func Check(t *testing.T, run Run, cases []Case)

Check runs every case with -h and with --help, in parallel subtests.

func HelpVerb

func HelpVerb(t *testing.T, run Run, tool string, verbs ...string)

HelpVerb checks `<tool> help <verb>` for a tool whose help verb takes one: the same help `<verb> -h` prints, on stdout, at exit 0, nothing on stderr.

func One

func One(t *testing.T, run Run, c Case, spelling string)

One runs one case with one spelling of help and asserts the rule.

func Problems

func Problems(run Run, c Case, spelling, dir string) []string

Problems runs one case with one spelling of help, with {dir} as dir, and returns every way it broke the rule; none is a pass.

Types

type Case

type Case struct {
	Verb  string
	Flags []string
}

Case is one verb ("send", "slots take") and the flags given before -h. "{dir}" and "{addr}" in a flag are replaced by the case's temp directory and RefusedAddr.

type Run

type Run func(args []string, stdout, stderr io.Writer) int

Run is the tool, in process: args after the tool's name, the two streams, the exit code.

Jump to

Keyboard shortcuts

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