Documentation
¶
Overview ¶
Package scriptenv is the shared environment of the testscript (.txtar) golden suite (issue #26 §5): the determinism environment every script runs under, the custom command set (daemon, clock, waitfor, capture, exitcode, cmpjson, cmpshape, mask), and the in-process daemon the inproc lane talks to.
Two lanes run through one Params: the inproc lane constructs the daemon inside the test process on a clock.Fake — the `messq` commands a script writes re-exec the test binary via testscript.RunMain and speak real HTTP over the socket — and the subproc lane (added with the quickstart/dev_mode scripts) runs a real `messq serve` where the process boundary is the thing under test.
This package is imported by tests only; nothing in the production tree links it. Its dependency on rogpeppe/go-internal is PLAN.md §13's test-only row.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Daemon ¶
type Daemon struct {
// contains filtered or unexported fields
}
Daemon is the inproc lane's daemon: the same construction pipeline `messq serve` runs (store.Open → api.New → writer engine with the waiter registry as its event sink → expiry sweeper), built inside the test process on a clock.Fake and listening on a unix socket under $WORK.
Scripts drive it through the REAL CLI: `messq <args…>` re-execs the test binary (testscript.RunMain) and talks HTTP over the socket, so every script exercises the same client/transport/API path production uses. The fake clock belongs to the test process; `clock advance` moves it between script lines.
func StartDaemon ¶
StartDaemon builds and starts the inproc daemon under workDir. It returns only once /readyz answers — the same readiness rule `messq serve`'s systemd unit relies on — so a script line that follows `daemon start` never races startup.
func (*Daemon) Quiesce ¶
Quiesce returns once everything issued before it has finished: a healthz round-trip through the real client gives a happens-after edge for the sweeper ticks `clock advance` fired. When delivery commands (#13/#14) land, this gains the writer-queue drain those scripts need; the scripts that exist today need no more than this barrier.
func (*Daemon) SocketPath ¶
SocketPath returns the bare socket path.
type State ¶
type State struct {
// contains filtered or unexported fields
}
state is the per-script state custom commands share: the fake clock, the inproc daemon (once `daemon start` ran), the script directory (-update needs it), and the update flag.
type Suite ¶
type Suite struct {
// Dir is the directory holding the .txtar scripts (testscript.Params.Dir).
Dir string
// Update mirrors the repo-wide -update convention: goldens rewrite instead of
// failing on drift. cmpshape assertions are NEVER rewritten — see [shapecheck].
Update bool
// FakeClockStart pins the inproc lane's fake clock. Zero means the suite
// default, so every script starts from the same instant.
FakeClockStart time.Time
}
Suite configures one testscript run. Tests build it, hand it to Params, and never touch the per-script state themselves.
func (*Suite) Params ¶
func (s *Suite) Params() testscript.Params
Params returns the testscript.Params for this suite: the command registry, the determinism setup, and the -update wiring.