]> Cypherpunks.ru repositories - gostls13.git/commitdiff
test: avoid matching file names in errcheck
authorRuss Cox <rsc@golang.org>
Tue, 18 Oct 2016 04:34:57 +0000 (00:34 -0400)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 18 Oct 2016 05:32:37 +0000 (05:32 +0000)
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>
test/fixedbugs/bug332.go
test/method2.go
test/run.go

index 91ae0b2ac883ec46ee398bec212c06c6ff2163b4..d43c2ddcff5981f5854057e9b60a6bc0741b7ff1 100644 (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"
\ No newline at end of file
+// 6g used to print <epoch> instead of bug332.go:111
+func (t *T) F() {} // ERROR "undefined: T"
\ No newline at end of file
index aaa850e7191c96171eaa173a44dd4033b7b43883..e55aee429b4f7c990b4df833f9edfed00883ecac 100644 (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"
index ad582f38e51472c0b68cf25157a8de45e86575dc..07eff4ddb9cb50fdf3360aecf84115b39559d093 100644 (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)