Documentation
¶
Overview ¶
Package cmdtest is the command line's tests' shared harness: a world of a MacPorts checkout, an upstream, and a fork (NewWorld), each test's stand-ins for compose and the host (Stands, Hosted), command lines run through them (Dockhand, RunFor, JSONOf), and the fakes a test gives the engine. A test binary hands Main the root's RunWith; cmdtest never imports the root, so a verb's external tests and the root's own run the same command line (part 4, item 2).
Index ¶
- Constants
- Variables
- func AsMaintainer(t *testing.T, w World)
- func BumpOn(t *testing.T, args ...string) (string, string, error)
- func Cells(results []model.TargetResult) []engine.Cell
- func Chdir(t testing.TB, dir string)
- func CleanupStamp(t *testing.T, home string) string
- func Dig(t *testing.T, value any, path ...any) any
- func Dockhand(t *testing.T, args ...string) (string, string, error)
- func Flat(text string) string
- func Getenv(t testing.TB, name string) string
- func Hosted(t testing.TB) *host.Host
- func Main(m *testing.M, run Runner)
- func Overwidth(out string) []string
- func RefusingSSH(t *testing.T, w World, g *forgetest.GitHub)
- func RunFor(t testing.TB, ctx context.Context, args []string, streams term.Streams) error
- func SaidOnce(out string) []string
- func Setenv(t testing.TB, name, value string)
- func Stands(t testing.TB) *compose.Dependencies
- func TestPlaces(t testing.TB) config.Places
- func TestSettings(t testing.TB) *settings.Settings
- func UseDependents(d *compose.Dependencies, reader engine.DependentReader)
- func UsePorts(d *compose.Dependencies, reader checks.PortReader)
- func Versioned(t *testing.T, w World)
- func WithAuth(t *testing.T, flow credential.DeviceFlow) memoryStore
- func WithBumper(t *testing.T)
- func WithGitHub(t *testing.T, w World) *forgetest.GitHub
- func WithOutcomeScript(t *testing.T, w World, config string) func(string)
- func WithOutdated(t *testing.T) *jqIsOutdated
- func WithScript(t *testing.T, w World, outcome string)
- type BuildHistories
- type Bumper
- type Decoded
- type JqDependents
- type OnePort
- type Refuser
- type Runner
- type SignedIn
- type SyncBuffer
- type UnfetchedPrevious
- type World
Constants ¶
const Settle = testsupport.Settle
Settle bounds a wait for what a running serve or watch says (testsupport.Settle).
Variables ¶
var YqMayBeOutdated = engine.OutdatedPort{Port: "yq", Current: "4.44.1", Newest: "5.0", Uncertain: []engine.SetAside{{Tag: "v5.0", Version: "5.0", Source: "5.0", Predates: "v4.44.1"}}}
YqMayBeOutdated is a port whose newest release is uncertain: v5.0 compares newer, but was tagged on a commit older than v4.44.1's.
Functions ¶
func AsMaintainer ¶
asMaintainer names the person as the fixture's maintainers lines do, for --mine.
func Cells ¶
func Cells(results []model.TargetResult) []engine.Cell
cells are hand-built results as the evidence's cells: recorded, but for a result not run, whose cell is of that kind.
func Chdir ¶
Chdir is the directory the test's command lines run in, as t.Chdir would make the process's.
func CleanupStamp ¶
cleanupStamp is the one checkout's cleanup stamp, kept for it beside the database.
func Flat ¶
Flat is text with its wrapped lines joined, each break and the indent after it one space, and its first line's indent dropped, for a test to read words whose wrap moves with what the line holds, as a temporary directory's path.
func Main ¶
Main keeps a test binary's command tests out of the person's own dockhand: a fresh HOME, so ~/.dockhand/dockhand.db is the tests', and none of the variables that point dockhand at a real tree, database, configuration, upstream, or token. On a Mac with MACPORTS_TREE set, a bare dockhand otherwise registered the person's checkout in their real database. Nor a shell's Tart homes, caches, or proxy, as the acceptance stage's (the M1's run at 10aac0c3: serve's test read its DOCKHAND_UPSTREAM's neighbours into the agent). It runs the tests with run as their command line.
func Overwidth ¶
Overwidth are a command line's lines wider than the width that could have been wrapped (term.Wrapped): not a table's, whose cells a terminal cuts, nor one with no space to break at, as a path or a URL.
func RefusingSSH ¶ added in v0.8.0
RefusingSSH points the fork's push URL at GitHub over SSH and has ssh refuse this Mac's key, in ssh's own words, as a fork that refuses the key does.
func SaidOnce ¶
SaidOnce is what a command line's default output breaks of "said once" (part 5, item 3, from the output review's §2): a pull request's URL, a run, or a commit named more than once outside a table, and more than one Next:. A line in a table, its cells set apart by two spaces or more, names what it's about in a column.
func Setenv ¶
Setenv sets a variable in the environment the test's command lines run with, as t.Setenv would in the process's, which a parallel test can't.
func Stands ¶
func Stands(t testing.TB) *compose.Dependencies
Stands are the test's stand-ins for what compose makes: the GitHub CLI isn't installed, so a test doesn't depend on the Mac running it.
func TestPlaces ¶
TestPlaces are the test's home and working directory, as a command run in it reads them.
func TestSettings ¶
TestSettings are a command's settings, with the test's stand-ins.
func UseDependents ¶
func UseDependents(d *compose.Dependencies, reader engine.DependentReader)
UseDependents gives a command run in the test reader as what finds dependents, and as what names a directory's ports, which names none where the reader doesn't.
func UsePorts ¶
func UsePorts(d *compose.Dependencies, reader checks.PortReader)
UsePorts gives a command run in the test reader as its port reader, with each capability the reader has, leaving any other given apart, as engine's usePorts does.
func WithAuth ¶
func WithAuth(t *testing.T, flow credential.DeviceFlow) memoryStore
func WithBumper ¶
func WithOutcomeScript ¶
withOutcomeScript configures a command provider that reports jq as ~/outcome says, "passed", or "failed" and the phase, install unless named, so a test can change what the next build does.
func WithOutdated ¶
Types ¶
type BuildHistories ¶ added in v0.8.0
type BuildHistories map[string]buildhistory.History
BuildHistories stand in for ports.macports.org's build history, by port: a port it holds has that history, and one it doesn't, no answer, so no test asks the network. It's an engine's BuilderHistory.
func (BuildHistories) History ¶ added in v0.8.0
func (h BuildHistories) History(_ context.Context, port string) (buildhistory.History, bool)
type Bumper ¶
type Bumper struct{ Repo *git.Repository }
Bumper stands in for MacPorts: a bump rewrites the version line, and a checksum refresh adds a checksums line.
type Decoded ¶
type Decoded struct {
Version int `json:"version"`
Command string `json:"command"`
ExitCode int `json:"exit_code"`
Error *string `json:"error"`
Result map[string]any `json:"result"`
// GitHubRequests is a pointer, so an envelope without it is told
// from one that sent none.
GitHubRequests *int64 `json:"github_requests"`
}
Decoded is a --json envelope, read back loosely.
type JqDependents ¶
type JqDependents struct{ Under bool }
jqDependents stands in for the port index: two ports depend on jq. jqDependents are jq's dependents, as the index has them; where under, jo links it under its +jq variant too, as variantDependents finds.
type OnePort ¶
type OnePort struct{}
OnePort stands in for MacPorts: every directory defines one port, named after it.
type Refuser ¶
type Refuser struct{}
refuser stands in for MacPorts with a Portfile dockhand won't edit.
type Runner ¶
type Runner func(context.Context, settings.Invocation, term.Streams, compose.Dependencies, *host.Host) error
Runner runs a command line, as the command line's root does (command.RunWith), which a test binary hands Main: cmdtest is below the root and never imports it, so a verb's external tests and the root's own run the same command line.
type SignedIn ¶
SignedIn stands in for the GitHub CLI: signed in as Account, it records what it marks ready; with no login, it isn't installed.
type SyncBuffer ¶
SyncBuffer is a buffer two goroutines may share.
func (*SyncBuffer) String ¶
func (s *SyncBuffer) String() string
type UnfetchedPrevious ¶
type UnfetchedPrevious struct{ Bumper }
unfetchedPrevious is the bumper, where the current version's archives couldn't be fetched to compare with the new one's.