-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types, types2: allow choice between reg. expression or not in ERROR test comments #51006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Per discussion with @findleyr: Let's use |
Change https://go.dev/cl/449736 mentions this issue: |
Change https://go.dev/cl/455718 mentions this issue: |
@findleyr If the regexp ends in a We can live with this (it's rare), or we can chose a different mechanism to distinguish between substring and regexp error patterns (e.g. |
Hmm, that's a good point that I hadn't considered. ERRORx seems like a reasonable alternative to me. |
Change https://go.dev/cl/456137 mentions this issue: |
Change https://go.dev/cl/456125 mentions this issue: |
Change https://go.dev/cl/456155 mentions this issue: |
Change https://go.dev/cl/455755 mentions this issue: |
… flexible Change the ErrorMap function to collect all comments with a comment text that matches a given regexp pattern. Also rename it to CommentMap. Adjust uses and corresponding test. Adjust various type-checker tests with incorrect ERROR patterns. For #51006. Change-Id: I749e8f31b532edbf8568f27ba1546dc849efd143 Reviewed-on: https://go-review.googlesource.com/c/go/+/456155 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cherry Mui <cherryyz@google.com>
This adds the (adjusted) syntax.CommentMap function and corresponding test to the types_test package so that we can use it for collecting ERROR comments in the next CL. For #51006. Change-Id: I63ce96e7394c28c02d5a292250586cc49c1f6e19 Reviewed-on: https://go-review.googlesource.com/c/go/+/456125 Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
Adjust the testFiles function to use the new commentMap function. This makes it possible for testFiles to match the types2.TestFiles logic more closely. For #51006. Change-Id: I6c5ecbeb86d095404ec04ba4452fb90d404b8280 Reviewed-on: https://go-review.googlesource.com/c/go/+/456137 Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
Before matching the pattern, the double quotes are simply stripped (no Go string unquoting) for now. This is a first step towards use of proper Go strings as ERROR patterns. The changes were obtained through a couple of global regexp find/replace commands: /\* ERROR ([^"]+) \*/ => /* ERROR "$1" */ // ERROR ([^"]+)$ => // ERROR "$1" followed up by manual fixes where multiple "/* ERROR"-style errors appeared on the same line (in that case, the first regexp matches the first and last ERROR). For #51006. Change-Id: Ib92c2d5e339075aeec1ea74c339b5fecf953d1a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/455718 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
… flexible Change the ErrorMap function to collect all comments with a comment text that matches a given regexp pattern. Also rename it to CommentMap. Adjust uses and corresponding test. Adjust various type-checker tests with incorrect ERROR patterns. For golang#51006. Change-Id: I749e8f31b532edbf8568f27ba1546dc849efd143 Reviewed-on: https://go-review.googlesource.com/c/go/+/456155 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cherry Mui <cherryyz@google.com>
Adjust the testFiles function to use the new commentMap function. This makes it possible for testFiles to match the types2.TestFiles logic more closely. For golang#51006. Change-Id: I6c5ecbeb86d095404ec04ba4452fb90d404b8280 Reviewed-on: https://go-review.googlesource.com/c/go/+/456137 Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
Before matching the pattern, the double quotes are simply stripped (no Go string unquoting) for now. This is a first step towards use of proper Go strings as ERROR patterns. The changes were obtained through a couple of global regexp find/replace commands: /\* ERROR ([^"]+) \*/ => /* ERROR "$1" */ // ERROR ([^"]+)$ => // ERROR "$1" followed up by manual fixes where multiple "/* ERROR"-style errors appeared on the same line (in that case, the first regexp matches the first and last ERROR). For golang#51006. Change-Id: Ib92c2d5e339075aeec1ea74c339b5fecf953d1a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/455718 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
… flexible Change the ErrorMap function to collect all comments with a comment text that matches a given regexp pattern. Also rename it to CommentMap. Adjust uses and corresponding test. Adjust various type-checker tests with incorrect ERROR patterns. For golang#51006. Change-Id: I749e8f31b532edbf8568f27ba1546dc849efd143 Reviewed-on: https://go-review.googlesource.com/c/go/+/456155 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cherry Mui <cherryyz@google.com>
Adjust the testFiles function to use the new commentMap function. This makes it possible for testFiles to match the types2.TestFiles logic more closely. For golang#51006. Change-Id: I6c5ecbeb86d095404ec04ba4452fb90d404b8280 Reviewed-on: https://go-review.googlesource.com/c/go/+/456137 Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
Before matching the pattern, the double quotes are simply stripped (no Go string unquoting) for now. This is a first step towards use of proper Go strings as ERROR patterns. The changes were obtained through a couple of global regexp find/replace commands: /\* ERROR ([^"]+) \*/ => /* ERROR "$1" */ // ERROR ([^"]+)$ => // ERROR "$1" followed up by manual fixes where multiple "/* ERROR"-style errors appeared on the same line (in that case, the first regexp matches the first and last ERROR). For golang#51006. Change-Id: Ib92c2d5e339075aeec1ea74c339b5fecf953d1a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/455718 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
go/types
andtypes2
(and thesyntax
package) rely onERROR
comments in test cases. Such a comment accepts a regular expression pattern that is then matched against the expected error:// ERROR regexp pattern
Often we just want to see if the error string appears verbatim (as a substring) in the error output, we don't need reg. expression matching. If we could choose a non-regexp string in those cases, we wouldn't need to escape various characters, which would make these
ERROR
comments more readable.Example:
// ERROR \*T2 does not implement I1 \(wrong type for method foo\)\n\t\thave foo\(x int\)\n\t\twant foo\(\)
would become
// ERROR *T2 does not implement I1 (wrong type for method foo)\n\t\thave foo(x int)\n\t\twant foo()
The non-regexp pattern might be the more common case. Maybe we could have
ERROR
andERRORx
(the latter is for regexp. matching).cc: @findleyr
The text was updated successfully, but these errors were encountered: