- Add globWithAffixes in runner/expander.go that wraps filepath.Glob
with an empty-match check and returns the computed prefix/suffix
from splitGlob, collapsing three near-identical lookup blocks in
expandGlobPattern into single calls.
- Extract per-case Test construction from buildTests into a new
buildTest helper so the loop body is a single call and the read /
assemble / arg-template logic lives in one place.
- Add Test.SetInputFile, Test.SetStdin, Test.SetOutputFile and
Test.SetStdout methods on dsl.Test to encapsulate the stdin-vs-
InFiles and stdout-vs-OutFiles wiring that buildTest previously
did inline.
- Adopt the `for range N` loop form in the determinism check in
runner/compiler_test.go.
- Switch the MSVC release test to expect /std:c17 since MSVC does
not ship a c11 mode (worth surfacing a warning about this later).
97 lines
1.6 KiB
Go
97 lines
1.6 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
|
|
|
|
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)}
|
|
}
|