go-shout/types.go

66 lines
1.2 KiB
Go

package main
// ExitCodeType describes how to match a command's exit code.
type ExitCodeType int
const (
ExitCodeNone ExitCodeType = iota // not specified — expect 0
ExitCodeExact // expect specific code
ExitCodeWildcard // [*] — expect any non-zero
)
type Command struct {
Line int
Raw string
Cmd string
Expected []string
ExitCodeType ExitCodeType
ExitCodeValue int
}
type Directive struct {
Type string // "setup" or "env"
Path string // for setup
Key string // for env
Value string // for env
Line int
}
type ShoutFile struct {
Path string
Commands []Command
Directives []Directive
}
type CommandResult struct {
Command Command
Actual []string
ExitCode int
}
type FileResult struct {
File ShoutFile
Results []CommandResult
TmpDir string
Error string
}
type DiffLine struct {
Kind string // "equal", "expected", "actual", "context"
Text string
}
type TestResult struct {
Path string
Passed bool
CommandCount int
Failures []FailedCommand
Error string
}
type FailedCommand struct {
Result CommandResult
DiffLines []DiffLine
ExitCodeMismatch bool
}