Documentation ¶
Index ¶
- func DropEol(s string) string
- func Escape(s string) string
- func ExecuteScript(workdir string, env []string, lines []string) ([]byte, error)
- func MakeBanner(u uuid.UUID) string
- func MakeEnvironment(path string) ([]string, error)
- func MakeScript(cmds []Command, banner string) (lines []string)
- func Patch(r io.Reader, w io.Writer, cmds []ExecutedCommand) (err error)
- func Unescape(s string) (string, error)
- type Command
- type Env
- type ExecutedCommand
- type ExecutedTest
- type InvalidTestError
- type Test
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DropEol ¶
DropEol removes a final end-of-line from s. It removes both Unix ("\n") and DOS ("\r\n") end-of-line characters.
func Escape ¶
Escape quotes non-printable characters in s with a backslash. If anything was changed, " (esc)" is added to the result. A final newline in s (if any) is kept unescaped.
func ExecuteScript ¶
Execute a script in the specified working directory.
func MakeBanner ¶
func MakeBanner(u uuid.UUID) string
MakeBanner turns a UUID into a nice banner we can recognize later in the output.
func MakeEnvironment ¶
MakeEnvironment prepares the environment to be used when executing the test in the given path. It currently sets TESTDIR to the dirname of path.
func MakeScript ¶
MakeScript produces a script ready to be sent to a shell. The banner should be a random string. It will be inserted in the output together with the exit status of each command.
Types ¶
type ExecutedCommand ¶
type ExecutedCommand struct { *Command // Command responsible for the output. ActualOutput []string // Actual output read from stdout and stderr. ActualExitCode int // Exit code. }
func ParseOutput ¶
func ParseOutput(cmds []Command, output []byte, banner string) ( executed []ExecutedCommand, err error)
ParseOutput finds the actual output and exit codes for a slice of commands. The result is a slice of executed commands. The actual output is normalized, meaning that a missing final EOL in the output is represented as noEolSuffix.
type ExecutedTest ¶
type ExecutedTest struct { Test ExecutedCmds []ExecutedCommand // All executed commands. Script string // The script passed to the shell. Failures []ExecutedCommand // Failed commands. }
ExecutedTest captures the executed commands, the script sent to the shell and the failed commands. The Test struct is embedded as a value instead of pointer to make the zero value for ExecutedTest immediatedly useful.
func Process ¶
func Process(tempdir, path string, idx int) (result ExecutedTest, err error)
Process parses a .t file, executes the test commands and compares the actual output to the expected output. The idx passed is used to make the working directory unique inside tempdir and must be different for each test file.
type InvalidTestError ¶
type InvalidTestError struct { Path string // Path to test file. Lineno int // Line number of failure Msg string // Error message }
func (*InvalidTestError) Error ¶
func (e *InvalidTestError) Error() string