mirror of https://github.com/golang/go.git
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:
parent
5a0d50f4eb
commit
57666c3fe8
|
|
@ -14,4 +14,4 @@ func main() {}
|
||||||
|
|
||||||
// important: no newline on end of next line.
|
// important: no newline on end of next line.
|
||||||
// 6g used to print <epoch> instead of bug332.go:111
|
// 6g used to print <epoch> instead of bug332.go:111
|
||||||
func (t *T) F() {} // ERROR "bug332"
|
func (t *T) F() {} // ERROR "undefined: T"
|
||||||
|
|
@ -33,5 +33,5 @@ var _ = (*Val).val // ERROR "method"
|
||||||
var v Val
|
var v Val
|
||||||
var pv = &v
|
var pv = &v
|
||||||
|
|
||||||
var _ = pv.val() // ERROR "method"
|
var _ = pv.val() // ERROR "pv.val undefined"
|
||||||
var _ = pv.val // ERROR "method"
|
var _ = pv.val // ERROR "pv.val undefined"
|
||||||
|
|
|
||||||
|
|
@ -855,7 +855,13 @@ func (t *test) errorCheck(outStr string, wantAuto bool, fullshort ...string) (er
|
||||||
matched := false
|
matched := false
|
||||||
n := len(out)
|
n := len(out)
|
||||||
for _, errmsg := range errmsgs {
|
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
|
matched = true
|
||||||
} else {
|
} else {
|
||||||
out = append(out, errmsg)
|
out = append(out, errmsg)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue