support

package
v0.1.32 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 24 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

View Source
const FailedDirName = "rotari-conformance-failed"

FailedDirName is the directory under os.TempDir where a failed test's evidence is kept.

Variables

This section is empty.

Functions

func AddedJobID

func AddedJobID(t *testing.T, result Result) string

func AssertPairOutcome

func AssertPairOutcome(t *testing.T, r Result)

func BuildRotari

func BuildRotari(path string) error

BuildRotari builds cmd/rotari at path for a conformance test binary. Commands that run the binary must call TrackBuildInputs.

func CommandEnv added in v0.1.30

func CommandEnv(vars []string, dir string) []string

CommandEnv is vars with PWD set to dir, as a shell sets it to the directory as the user named it. Without it, os.Getwd returns the resolved path, which differs where the temporary directory is under a symbolic link, as /var is on macOS.

func GuardedCommands

func GuardedCommands(project string) map[string][]string

GuardedCommands are the project commands that a running or interrupted project rejects. Queue edits are not among them: the queue holds only the next run's jobs.

func JobProcesses

func JobProcesses(t *testing.T, root, job string) int

func KeepOnFailure added in v0.1.30

func KeepOnFailure(t *testing.T, root string, transcript *Transcript)

KeepOnFailure keeps the evidence of a failed test: when t has failed, its state directory root is moved to a new directory under os.TempDir()/FailedDirName, with the transcript beside it as commands.log, and the place is logged. A passing test keeps nothing. Register it before the cleanups that stop the test's servers and processes, so that it runs after them.

func KillProcessGroup

func KillProcessGroup(pid int) error

func KillStrays

func KillStrays(t *testing.T, root string)

func KillSupervisors

func KillSupervisors(t *testing.T, root string)

KillSupervisors kills the supervisor processes of runs under root, as a crash would, and leaves their jobs running. It returns once they are gone, so a caller that then stops the jobs cannot let a supervisor record their results.

func MemoryTempDir added in v0.1.20

func MemoryTempDir(t *testing.T) string

MemoryTempDir returns a directory on /dev/shm when it is writable, removed when the test ends, and t.TempDir otherwise. jj syncs its operation log to disk on every snapshot, which takes seconds on a host busy with synchronous writes, so jj repositories made by tests live in memory.

func NonUTF8NamesAllowed added in v0.1.30

func NonUTF8NamesAllowed(t interface {
	Helper()
	Logf(string, ...any)
	Fatal(...any)
}, dir string) bool

NonUTF8NamesAllowed reports whether the file system under dir holds a name that is not UTF-8. macOS (APFS) refuses one with EILSEQ; there a test checks everything else and leaves such names out.

func PairAdapter

func PairAdapter(command string) string

One execution classification shared by the inventory and runners. Missing adapters are deferred explicitly rather than counted as passing tests.

func PairHasFlag

func PairHasFlag(flags []PairFlag, name string) bool

func PairIntersect

func PairIntersect(a, b []string) []string

func PairMutationRevision

func PairMutationRevision(t *testing.T, e *Env) string

func ProcessArgs added in v0.1.30

func ProcessArgs(pid int) ([]string, bool, error)

ProcessArgs returns pid's arguments, or false when it is not running.

func ProcessEnvironment added in v0.1.30

func ProcessEnvironment(pid int) ([]string, error)

ProcessEnvironment returns pid's environment as NAME=VALUE entries: from /proc on Linux and from ps -E elsewhere, where entries follow the arguments split at spaces. It fails when pid is gone or not this user's.

func Run

func Run(m *testing.M) int

func TrackBuildInputs

func TrackBuildInputs(t testing.TB)

TrackBuildInputs makes a cached test result depend on rotari's sources.

BuildRotari runs `go build` in a subprocess, which Go's test cache does not observe, so a cached conformance result would survive a change to rotari. The cache does record files the test process stats while tests run (not in TestMain), so every command that runs the built binary calls this: it stats each file under the module's cmd and internal directories, plus go.mod and go.sum, once per test binary.

func WaitForInterrupted

func WaitForInterrupted(t *testing.T, e *Env, project string)

func WaitUntil

func WaitUntil(t *testing.T, timeout time.Duration, done func() (bool, string))

Types

type ActiveRun

type ActiveRun struct {
	Project string
	RunID   string
	Jobs    []string
}

type CoordinatorProcess

type CoordinatorProcess struct {
	Host         string `json:"host"`
	PID          int    `json:"pid"`
	PIDNamespace string `json:"pid_namespace"`
	ProcessStart string `json:"process_start"`
}

func CurrentCoordinator

func CurrentCoordinator(t *testing.T) CoordinatorProcess

func ProcessIdentity

func ProcessIdentity(t *testing.T, pid int) CoordinatorProcess

type Env

type Env struct {
	T      *testing.T
	Root   string
	Base   string
	Master string
	// contains filtered or unexported fields
}

func NewEnv

func NewEnv(t *testing.T) *Env

func (*Env) CheckState

func (e *Env) CheckState(project string) string

func (*Env) Command

func (e *Env) Command(args ...string) *exec.Cmd

Command returns an unstarted rotari command in e's environment, for a test that talks to the process itself, such as over its stdin.

func (*Env) CreateFinishedRun

func (e *Env) CreateFinishedRun() FinishedRun

func (*Env) ExportFinishedRun

func (e *Env) ExportFinishedRun(project string) string

func (*Env) FinishedJobRun

func (e *Env) FinishedJobRun(project string) (runID, attemptID string)

func (*Env) HTTPDo

func (e *Env) HTTPDo(method, url string, headers map[string]string, body string) HTTPResult

HTTPDo sends one request with headers; a "Host" header sets the request's Host. body, when not empty, is sent as JSON.

func (*Env) HTTPGet

func (e *Env) HTTPGet(url string) HTTPResult

func (*Env) HTTPPostJSON

func (e *Env) HTTPPostJSON(url string, body any) HTTPResult

func (*Env) In

func (e *Env) In(dir string) *Env

In returns a copy of e whose commands run in dir.

func (*Env) JobExitStatus

func (e *Env) JobExitStatus(project, jobID string) string

func (*Env) MustRotari

func (e *Env) MustRotari(args ...string) Result

func (*Env) OrphanRun

func (e *Env) OrphanRun(project, script string) string

func (*Env) Rotari

func (e *Env) Rotari(args ...string) Result

func (*Env) RotariRun added in v0.1.20

func (e *Env) RotariRun(args ...string) Result

RotariRun runs a run or retry that must start a run, whatever its jobs do. A refusal to start also exits 1, like a run whose jobs failed, so it fails the test with the command's output unless a new run directory appeared in e's basedir or one the arguments name.

func (*Env) Setenv

func (e *Env) Setenv(name, value string)

Setenv sets name in the environment of e's later commands.

func (*Env) StartRun

func (e *Env) StartRun(project string, count int, async bool, runArgs ...string) ActiveRun

func (*Env) StartTableView

func (e *Env) StartTableView(path string, args ...string) string

StartTableView starts rotari tableview on path and returns its URL.

func (*Env) StartWeb

func (e *Env) StartWeb(args ...string) string

func (*Env) WithVar

func (e *Env) WithVar(name, value string) *Env

func (*Env) Without

func (e *Env) Without(name string) *Env

type FinishedRun

type FinishedRun struct {
	Project    string
	RunID      string
	OKJob      string
	BadJob     string
	BadAttempt string
}

type FlagPair

type FlagPair struct{ A, B PairFlag }

func CommandFlagPairs

func CommandFlagPairs(c PairCommand) []FlagPair

type HTTPResult

type HTTPResult struct {
	Status int
	Body   string
}

type PairCommand

type PairCommand struct {
	Name  string     `json:"name"`
	Flags []PairFlag `json:"flags"`
}

func ReadPairSchema

func ReadPairSchema(t *testing.T, e *Env) []PairCommand

type PairFixture

type PairFixture struct {
	E                                *Env
	Project, Run, Bad, Array, Config string
	Jobs                             []string
}

func NewPairFixture

func NewPairFixture(t *testing.T) PairFixture

func (PairFixture) Sample

func (f PairFixture) Sample(t *testing.T, flag PairFlag) []string

type PairFlag

type PairFlag struct {
	Name      string   `json:"name"`
	ValueName string   `json:"value_name"`
	Values    []string `json:"values"`
}

type PairMutationFixture

type PairMutationFixture struct {
	PairFixture
	Initial PairSavedTree
	// Current is the tree as last observed after an invocation; Restore
	// diffs against it.
	Current   *PairSavedTree
	Revision  string
	SecondRun string
	Manifest  string
}

func NewPairMutationFixture

func NewPairMutationFixture(t *testing.T) PairMutationFixture

type PairMutationResult

type PairMutationResult struct {
	Process Result
	State   map[string]string
}

type PairSavedFile

type PairSavedFile struct {
	Path string
	Mode fs.FileMode
	At   time.Time
	Data []byte
	Dir  bool
}

type PairSavedTree

type PairSavedTree []PairSavedFile

A byte-for-byte initial tree, including directory mtimes used by latest-run lookup. All paths are relative to the harness-owned temporary root. No active supervisor/job is allowed while this snapshot is captured or restored.

func SavePairTree

func SavePairTree(t *testing.T, root string) PairSavedTree

func (PairSavedTree) Observation

func (tree PairSavedTree) Observation(t *testing.T) map[string]string

Only the project's newly written meta.updated_at is nondeterministic. All other content (IDs, queue definitions, results, registry, modes) stays exact.

func (PairSavedTree) Raw

func (tree PairSavedTree) Raw() map[string]string

func (PairSavedTree) Restore

func (tree PairSavedTree) Restore(t *testing.T, root string, current PairSavedTree)

Restore returns root to tree, given current, the snapshot taken after the last invocation. It rewrites only entries that differ, which matters on network filesystems where rewriting the whole tree per invocation dominated the runtime. Every entry's path, type, mode, and modification time is then checked against tree; contents are exact because unchanged entries had equal contents in current and changed ones are rewritten from tree.

type Process added in v0.1.30

type Process struct {
	PID, PPID, PGID int
	// Args are the command-line arguments. On Linux they are exact; elsewhere
	// they come from ps and are split at spaces, so an argument holding a space
	// reads as several. Tests match paths without spaces and whole words.
	Args []string
}

Process is one entry of the process table, as tests look at it from outside.

func MustProcesses added in v0.1.30

func MustProcesses(t interface {
	Helper()
	Fatalf(string, ...any)
}) []Process

MustProcesses is Processes, failing the test on an error rather than letting a caller find nothing and pass.

func Processes added in v0.1.30

func Processes() ([]Process, error)

Processes lists the processes this user can see: from /proc on Linux, and from ps elsewhere. A process that has exited but is not yet reaped has no arguments.

func (Process) CommandLine added in v0.1.30

func (p Process) CommandLine() string

CommandLine joins the arguments with spaces, for substring matches.

func (Process) HasArg added in v0.1.30

func (p Process) HasArg(arg string) bool

HasArg reports whether one argument is exactly arg.

type Result

type Result struct {
	Args   []string
	Code   int
	Stdout string
	Stderr string
}

func PairInvoke

func PairInvoke(t *testing.T, e *Env, args ...string) Result

Adapters own isolation and restoration for mutating commands. Finished runs ensure --follow exits; the deadline is a failure bound, never an expected result. It is 20 s: 5 s was exceeded by cancel --wait on a loaded macOS runner under the race detector, and 20 s still stops short of the 30-second grace period a cancel waits when its job does not end, so that fault still shows.

func (Result) String

func (r Result) String() string

type Transcript added in v0.1.30

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

Transcript records the rotari commands a test runs: when each started, in which directory, and, for commands run to completion, their exit code and full output. It is written out only when the test fails.

func (*Transcript) Finished added in v0.1.30

func (transcript *Transcript) Finished(args []string, code int, stdout, stderr string, elapsed time.Duration)

Finished records a command that ran to completion.

func (*Transcript) Started added in v0.1.30

func (transcript *Transcript) Started(dir string, args []string)

Started records a command that is about to start.

Jump to

Keyboard shortcuts

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