some fixes
All checks were successful
go-test / go test (push) Successful in 26s
Release / Build & publish (push) Successful in 59s

This commit is contained in:
2026-06-10 09:55:25 +03:00
parent cbc000e872
commit 1ef3973a15
7 changed files with 246 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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"