107 lines
2.1 KiB
Go
107 lines
2.1 KiB
Go
package dsl
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
type File struct {
|
|
Build string
|
|
BuildLinux string
|
|
BuildWindows string
|
|
BuildDarwin string
|
|
|
|
BuildDefaults *BuildConfig
|
|
Builds []*BuildConfig
|
|
Toolchains []*ToolchainSpec
|
|
|
|
Timeout time.Duration
|
|
MemoryLimit int64
|
|
Binary string
|
|
Sources string
|
|
|
|
NormalizeCRLF bool
|
|
TrimTrailingWS bool
|
|
|
|
Groups []*Group
|
|
}
|
|
|
|
type Group struct {
|
|
Name string
|
|
Weight float64
|
|
Timeout time.Duration
|
|
MemoryLimit int64
|
|
Env map[string]string
|
|
Scoring ScoringMode
|
|
Wrapper string
|
|
|
|
Tests []*Test
|
|
Pattern *Pattern
|
|
}
|
|
|
|
type ScoringMode int
|
|
|
|
const (
|
|
ScoringPartial ScoringMode = iota
|
|
ScoringAllOrNone
|
|
)
|
|
|
|
type Pattern struct {
|
|
InputGlob string
|
|
OutputGlob string
|
|
|
|
DirsGlob string
|
|
InputFile string
|
|
OutputFile string
|
|
|
|
// StageAll, valid only in dir mode, stages every file found in each matched
|
|
// directory into the test's working directory (basenames preserved), except
|
|
// the OutputFile and ArgsFile. Use it when the program discovers its own
|
|
// inputs in the working directory instead of receiving a single input file.
|
|
StageAll bool
|
|
// ArgsFile, valid only in dir mode, reads the program arguments from this
|
|
// file inside each matched directory (whitespace-separated). It takes
|
|
// precedence over Args. Placeholders are still substituted.
|
|
ArgsFile string
|
|
|
|
Args []string
|
|
}
|
|
|
|
func (p *Pattern) IsDirMode() bool {
|
|
return p.DirsGlob != ""
|
|
}
|
|
|
|
type Test struct {
|
|
Name string
|
|
Timeout time.Duration
|
|
MemoryLimit int64
|
|
Env map[string]string
|
|
Wrapper string
|
|
|
|
Stdin *string
|
|
Args []string
|
|
InFiles map[string]string
|
|
|
|
ExitCode *int
|
|
Stdout Matcher
|
|
Stderr Matcher
|
|
OutFiles map[string]string
|
|
}
|
|
|
|
func (t *Test) SetInputFile(inputName string, inputContent []byte) {
|
|
t.InFiles[inputName] = string(inputContent)
|
|
}
|
|
|
|
func (t *Test) SetStdin(inputContent []byte) {
|
|
s := string(inputContent)
|
|
t.Stdin = &s
|
|
}
|
|
|
|
func (t *Test) SetOutputFile(outputName string, outputContent []byte) {
|
|
t.OutFiles[outputName] = string(outputContent)
|
|
t.Stdout = NoMatcher{}
|
|
}
|
|
|
|
func (t *Test) SetStdout(outputContent []byte) {
|
|
t.Stdout = ExactMatcher{Value: string(outputContent)}
|
|
}
|