donec chan bool // closed when done
dt time.Duration
- src string
- action string // "compile", "build", etc.
+ src string
tempDir string
err error
pkgPos = pos // some files are intentionally malformed
}
if ok, why := shouldTest(t.src[:pkgPos], goos, goarch); !ok {
- t.action = "skip"
if *showSkips {
- fmt.Printf("%-20s %-20s: %s\n", t.action, t.goFileName(), why)
+ fmt.Printf("%-20s %-20s: %s\n", "skip", t.goFileName(), why)
}
return
}
var args, flags []string
wantError := false
+ wantAuto := false
singlefilepkgs := false
f := strings.Fields(action)
if len(f) > 0 {
switch action {
case "rundircmpout":
action = "rundir"
- t.action = "rundir"
case "cmpout":
action = "run" // the run case already looks for <dir>/<test>.out files
- fallthrough
case "compile", "compiledir", "build", "run", "runoutput", "rundir":
- t.action = action
+ // nothing to do
case "errorcheckandrundir":
wantError = false // should be no error if also will run
- fallthrough
+ case "errorcheckwithauto":
+ action = "errorcheck"
+ wantAuto = true
+ wantError = true
case "errorcheck", "errorcheckdir", "errorcheckoutput":
- t.action = action
wantError = true
case "skip":
if *runSkips {
break
}
- t.action = "skip"
return
default:
t.err = skipError("skipped; unknown pattern: " + action)
- t.action = "??"
return
}
if *updateErrors {
t.updateErrors(string(out), long)
}
- t.err = t.errorCheck(string(out), long, t.gofile)
+ t.err = t.errorCheck(string(out), wantAuto, long, t.gofile)
return
case "compile":
for _, name := range gofiles {
fullshort = append(fullshort, filepath.Join(longdir, name), name)
}
- t.err = t.errorCheck(string(out), fullshort...)
+ t.err = t.errorCheck(string(out), wantAuto, fullshort...)
if t.err != nil {
break
}
return
}
}
- t.err = t.errorCheck(string(out), tfile, "tmp__.go")
+ t.err = t.errorCheck(string(out), false, tfile, "tmp__.go")
return
}
}
return string(b)
}
-func splitOutput(out string) []string {
+func splitOutput(out string, wantAuto bool) []string {
// gc error messages continue onto additional lines with leading tabs.
// Split the output at the beginning of each line that doesn't begin with a tab.
// <autogenerated> lines are impossible to match so those are filtered out.
}
if strings.HasPrefix(line, "\t") {
res[len(res)-1] += "\n" + line
- } else if strings.HasPrefix(line, "go tool") || strings.HasPrefix(line, "<autogenerated>") || strings.HasPrefix(line, "#") {
+ } else if strings.HasPrefix(line, "go tool") || strings.HasPrefix(line, "#") || !wantAuto && strings.HasPrefix(line, "<autogenerated>") {
continue
} else if strings.TrimSpace(line) != "" {
res = append(res, line)
return res
}
-func (t *test) errorCheck(outStr string, fullshort ...string) (err error) {
+func (t *test) errorCheck(outStr string, wantAuto bool, fullshort ...string) (err error) {
defer func() {
if *verbose && err != nil {
log.Printf("%s gc output:\n%s", t, outStr)
}
}()
var errs []error
- out := splitOutput(outStr)
+ out := splitOutput(outStr, wantAuto)
// Cut directory name.
for i := range out {
for _, we := range want {
var errmsgs []string
- errmsgs, out = partitionStrings(we.prefix, out)
+ if we.auto {
+ errmsgs, out = partitionStrings("<autogenerated>", out)
+ } else {
+ errmsgs, out = partitionStrings(we.prefix, out)
+ }
if len(errmsgs) == 0 {
errs = append(errs, fmt.Errorf("%s:%d: missing error %q", we.file, we.lineNum, we.reStr))
continue
// Parse new errors.
errors := make(map[int]map[string]bool)
tmpRe := regexp.MustCompile(`autotmp_[0-9]+`)
- for _, errStr := range splitOutput(out) {
+ for _, errStr := range splitOutput(out, false) {
colon1 := strings.Index(errStr, ":")
if colon1 < 0 || errStr[:colon1] != file {
continue
reStr string
re *regexp.Regexp
lineNum int
+ auto bool // match <autogenerated> line
file string
prefix string
}
var (
errRx = regexp.MustCompile(`// (?:GC_)?ERROR (.*)`)
+ errAutoRx = regexp.MustCompile(`// (?:GC_)?ERRORAUTO (.*)`)
errQuotesRx = regexp.MustCompile(`"([^"]*)"`)
lineRx = regexp.MustCompile(`LINE(([+-])([0-9]+))?`)
)
// double comment disables ERROR
continue
}
- m := errRx.FindStringSubmatch(line)
+ var auto bool
+ m := errAutoRx.FindStringSubmatch(line)
+ if m != nil {
+ auto = true
+ } else {
+ m = errRx.FindStringSubmatch(line)
+ }
if m == nil {
continue
}
reStr: rx,
re: re,
prefix: prefix,
+ auto: auto,
lineNum: lineNum,
file: short,
})