1
0
mirror of https://github.com/golang/go synced 2024-11-26 06:27:58 -07:00

test: avoid matching file names in errcheck

Fixes #17030.

Change-Id: Ic7f237ac7553ae0176929056e64b01667ed59066
Reviewed-on: https://go-review.googlesource.com/31351
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Russ Cox 2016-10-18 00:34:57 -04:00 committed by Brad Fitzpatrick
parent 5a0d50f4eb
commit 57666c3fe8
3 changed files with 11 additions and 5 deletions

View File

@ -13,5 +13,5 @@ func main() {}
// issue 1474
// important: no newline on end of next line.
// 6g used to print <epoch> instead of bug332.go:111
func (t *T) F() {} // ERROR "bug332"
// 6g used to print <epoch> instead of bug332.go:111
func (t *T) F() {} // ERROR "undefined: T"

View File

@ -33,5 +33,5 @@ var _ = (*Val).val // ERROR "method"
var v Val
var pv = &v
var _ = pv.val() // ERROR "method"
var _ = pv.val // ERROR "method"
var _ = pv.val() // ERROR "pv.val undefined"
var _ = pv.val // ERROR "pv.val undefined"

View File

@ -855,7 +855,13 @@ func (t *test) errorCheck(outStr string, wantAuto bool, fullshort ...string) (er
matched := false
n := len(out)
for _, errmsg := range errmsgs {
if we.re.MatchString(errmsg) {
// Assume errmsg says "file:line: foo".
// Cut leading "file:line: " to avoid accidental matching of file name instead of message.
text := errmsg
if i := strings.Index(text, " "); i >= 0 {
text = text[i+1:]
}
if we.re.MatchString(text) {
matched = true
} else {
out = append(out, errmsg)