Documentation
¶
Overview ¶
Package bound runs a harness binding's commands: one command line, as a subprocess of the engine with a deadline, its output captured. The command runs in a process group of its own, and the whole group is killed at the deadline or when the caller's context ends, so nothing the command started can make the engine wait past it. It works on Linux and macOS; elsewhere Run refuses.
It also says what goes into a bound command: Fill fills a line's placeholders and Environ builds the environment a run's commands get, for the start command, which runs in the engine's pty, as for the ones Run runs. And it reads what a result command printed: Outcome.Result.
Index ¶
Constants ¶
const MaxStdout = 64 << 10
MaxStdout is how many bytes of a command's standard output are kept: its start.
Variables ¶
This section is empty.
Functions ¶
func Environ ¶
Environ returns a new environment for a run's commands: base without the agent session's variables, the terminal's and any earlier PHYSA_RUN, PHYSA_CHANGE or PHYSA_SPEC, then TERM=xterm-256color and the run, change and spec file added. Every other variable is kept as it is.
func Fill ¶
Fill returns line with every {change} replaced by change, as the Change: trailer names it (<pursuit>/<change>), and every {run} by run, the run's number. A value made only of letters, digits, '_', '.', '/' and '-' goes in as written, so a placeholder inside a quoted argument still works; any other value is single-quoted, each ' in it written as quote, backslash, quote, quote. Pursuit slugs and change names are slugs today, so the quoting is a defence.
Types ¶
type Command ¶
type Command struct {
// Line is the command line, run as /bin/sh -c Line.
Line string
// Dir is the directory the command runs in.
Dir string
// Env is the command's whole environment, as KEY=value lines; nothing is
// taken from the engine's own.
Env []string
// Timeout is the command's deadline, from its start.
Timeout time.Duration
// Tail is how many bytes of the command's standard error are kept: its
// end.
Tail int
}
Command is one bound command line to run.
type Outcome ¶
Outcome is how a command ended. Err is set when it could not be run at all. Cut is set when it was killed, at its deadline or because the caller's context ended; Code then means nothing.
func (Outcome) Result ¶
Result reads a result command's outcome: the result it printed, or the reason it printed none: it was cut at its deadline, could not be run, exited with a code other than 0, or its standard output is not one JSON object. Keys it does not know are ignored. Whether the branch, commit and pr are acceptable is the store's to say.