1
1
mirror of https://github.com/wader/fq.git synced 2024-10-26 20:06:29 +03:00

Merge pull request #393 from wader/fqtest-speedup

Speed up tests by fixing script parser output collecting and run tests in parallell
This commit is contained in:
Mattias Wadman 2022-08-23 20:24:23 +02:00 committed by GitHub
commit fc0414dfc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -374,6 +374,8 @@ type Section struct {
LineNr int
Name string
Value string
valueSB strings.Builder
}
func SectionParser(re *regexp.Regexp, s string) []Section {
@ -407,11 +409,16 @@ func SectionParser(re *regexp.Regexp, s string) []Section {
cs.LineNr = lineNr
cs.Name = firstMatch(sm, func(s string) bool { return len(s) != 0 })
} else {
// TODO: use builder somehow if performance is needed
cs.Value += l + lineDelim
cs.valueSB.WriteString(l)
cs.valueSB.WriteString(lineDelim)
}
}
for i := range sections {
cs := &sections[i]
cs.Value = cs.valueSB.String()
}
return sections
}

View File

@ -18,6 +18,8 @@ func TestPath(t *testing.T, registry *interp.Registry) {
ColorDiff: os.Getenv("DIFF_COLOR") != "",
WriteOutput: os.Getenv("WRITE_ACTUAL") != "",
Fn: func(t *testing.T, path, input string) (string, string, error) {
t.Parallel()
b, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)