some fixes
This commit is contained in:
10
dsl/ast.go
10
dsl/ast.go
@@ -53,6 +53,16 @@ type Pattern struct {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -807,6 +807,18 @@ func (p *Parser) parsePattern() (*Pattern, error) {
|
||||
return nil, err
|
||||
}
|
||||
pat.DirsGlob = val.Value
|
||||
case "stage":
|
||||
b, err := p.parseBool()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pat.StageAll = b
|
||||
case "args_file":
|
||||
val, err := p.expect(TOKEN_STRING)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pat.ArgsFile = val.Value
|
||||
case "args":
|
||||
xs, err := p.parseStringList()
|
||||
if err != nil {
|
||||
|
||||
@@ -37,6 +37,38 @@ group("g") {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePatternStageAllMode(t *testing.T) {
|
||||
src := `
|
||||
build "make"
|
||||
group("g") {
|
||||
weight = 1.0
|
||||
pattern {
|
||||
dirs = "testdata/test_*"
|
||||
stage = true
|
||||
args_file = "args.txt"
|
||||
output = "answer.txt"
|
||||
}
|
||||
}
|
||||
`
|
||||
f, _, err := Parse(src)
|
||||
if err != nil {
|
||||
t.Fatalf("parse: %v", err)
|
||||
}
|
||||
pat := f.Groups[0].Pattern
|
||||
if pat == nil {
|
||||
t.Fatal("no pattern")
|
||||
}
|
||||
if !pat.StageAll {
|
||||
t.Error("StageAll = false, want true")
|
||||
}
|
||||
if pat.ArgsFile != "args.txt" {
|
||||
t.Errorf("ArgsFile = %q", pat.ArgsFile)
|
||||
}
|
||||
if pat.OutputFile != "answer.txt" {
|
||||
t.Errorf("OutputFile = %q", pat.OutputFile)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePatternUnknownField(t *testing.T) {
|
||||
src := `
|
||||
build "make"
|
||||
|
||||
Reference in New Issue
Block a user