Documentation
¶
Overview ¶
Package tscmd holds the custom testscript commands the Brigade scripts use. They close five gaps in testscript's builtin set (plan 9.1):
status <exit-code> <command> [args...]
Run a command and assert its exact exit status, leaving stdout and
stderr in place for the checks that follow. The builtin `exec`
asserts only success, and `! exec` only failure, so neither can tell
a `usage` (2) from a `not_found` (6) — and the exit code is half of
Brigade's error contract (4.6).
json <stdout|stderr|file> <.dotted.path> <expected> (negatable)
Assert one field of a JSON document. The builtin `stdout` is a
regexp over the whole stream, which passes on a document that
happens to contain the text somewhere else.
jsonenv <stdout|stderr|file> <.dotted.path> <VAR>
Export one field into the script environment, so a value printed by
one command can be an argument to the next.
expand <in> <out>
Write <in> to <out> with $VAR expanded, so a script can build the
stdin document for the next command out of values it just learned.
sleeper
Start a `sleep 300` child, reap it, and export $SLEEPER_PID. It
stands in for a live Claude Code process. Reaping matters: kill(pid,
0) keeps succeeding on an unreaped zombie, which is the false
positive E0-5 measured at 27.6 s and 59.0 s.
A note that matters for anything added here: these commands must not call ts.Stdout or ts.Stderr. testscript replaces the script's stdout and stderr with a builtin command's own buffers the moment either is called, so `status` would erase the output of the command it just ran.
Index ¶
- func Commands() map[string]func(ts *testscript.TestScript, neg bool, args []string)
- func Expand(ts *testscript.TestScript, neg bool, args []string)
- func JSON(ts *testscript.TestScript, neg bool, args []string)
- func JSONEnv(ts *testscript.TestScript, neg bool, args []string)
- func Sleeper(ts *testscript.TestScript, neg bool, args []string)
- func Status(ts *testscript.TestScript, neg bool, args []string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Commands ¶
func Commands() map[string]func(ts *testscript.TestScript, neg bool, args []string)
Commands returns the command table to put in testscript.Params.Cmds.
func Expand ¶
func Expand(ts *testscript.TestScript, neg bool, args []string)
Expand implements `expand <in> <out>`.
func JSON ¶
func JSON(ts *testscript.TestScript, neg bool, args []string)
JSON implements `json <stdout|stderr|file> <.dotted.path> <expected>`.
func JSONEnv ¶
func JSONEnv(ts *testscript.TestScript, neg bool, args []string)
JSONEnv implements `jsonenv <stdout|stderr|file> <.dotted.path> <VAR>`.
func Sleeper ¶
func Sleeper(ts *testscript.TestScript, neg bool, args []string)
Sleeper implements `sleeper`.
func Status ¶
func Status(ts *testscript.TestScript, neg bool, args []string)
Status implements `status <exit-code> <command> [args...]`.
Types ¶
This section is empty.