Commit 68de5508 authored by Yury Smolsky's avatar Yury Smolsky Committed by Brad Fitzpatrick

cmd/vet: eliminate use of Perl in tests

This change uses errorCheck and wantedErrors functions copied from
the test/run.go to eliminate use of the test/errchk perl script.

Tests' error messages that contained full filenames were changed to
have base filenames because the errorCheck function processes output
from "go vet" in the same way.

Fixes #20032.

Change-Id: Ieb7be67c2d7281b9648171c698398449b7e2d4dd
Reviewed-on: https://go-review.googlesource.com/114176
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
parent 4fe688c6
...@@ -43,7 +43,7 @@ func AtomicTests() { ...@@ -43,7 +43,7 @@ func AtomicTests() {
{ {
// A variable declaration creates a new variable in the current scope. // A variable declaration creates a new variable in the current scope.
x := atomic.AddUint64(&x, 1) // ERROR "declaration of .x. shadows declaration at testdata/atomic.go:16" x := atomic.AddUint64(&x, 1) // ERROR "declaration of .x. shadows declaration at atomic.go:16"
// Re-declaration assigns a new value. // Re-declaration assigns a new value.
x, w := atomic.AddUint64(&x, 1), 10 // ERROR "direct assignment to atomic value" x, w := atomic.AddUint64(&x, 1), 10 // ERROR "direct assignment to atomic value"
......
...@@ -17,7 +17,7 @@ func ShadowRead(f *os.File, buf []byte) (err error) { ...@@ -17,7 +17,7 @@ func ShadowRead(f *os.File, buf []byte) (err error) {
_ = err _ = err
} }
if f != nil { if f != nil {
_, err := f.Read(buf) // ERROR "declaration of .err. shadows declaration at testdata/shadow.go:13" _, err := f.Read(buf) // ERROR "declaration of .err. shadows declaration at shadow.go:13"
if err != nil { if err != nil {
return err return err
} }
...@@ -25,8 +25,8 @@ func ShadowRead(f *os.File, buf []byte) (err error) { ...@@ -25,8 +25,8 @@ func ShadowRead(f *os.File, buf []byte) (err error) {
_ = i _ = i
} }
if f != nil { if f != nil {
x := one() // ERROR "declaration of .x. shadows declaration at testdata/shadow.go:14" x := one() // ERROR "declaration of .x. shadows declaration at shadow.go:14"
var _, err = f.Read(buf) // ERROR "declaration of .err. shadows declaration at testdata/shadow.go:13" var _, err = f.Read(buf) // ERROR "declaration of .err. shadows declaration at shadow.go:13"
if x == 1 && err != nil { if x == 1 && err != nil {
return err return err
} }
...@@ -46,7 +46,7 @@ func ShadowRead(f *os.File, buf []byte) (err error) { ...@@ -46,7 +46,7 @@ func ShadowRead(f *os.File, buf []byte) (err error) {
if shadowTemp := shadowTemp; true { // OK: obviously intentional idiomatic redeclaration if shadowTemp := shadowTemp; true { // OK: obviously intentional idiomatic redeclaration
var f *os.File // OK because f is not mentioned later in the function. var f *os.File // OK because f is not mentioned later in the function.
// The declaration of x is a shadow because x is mentioned below. // The declaration of x is a shadow because x is mentioned below.
var x int // ERROR "declaration of .x. shadows declaration at testdata/shadow.go:14" var x int // ERROR "declaration of .x. shadows declaration at shadow.go:14"
_, _, _ = x, f, shadowTemp _, _, _ = x, f, shadowTemp
} }
// Use a couple of variables to trigger shadowing errors. // Use a couple of variables to trigger shadowing errors.
......
...@@ -44,40 +44,40 @@ type AnonymousXML struct{} ...@@ -44,40 +44,40 @@ type AnonymousXML struct{}
type DuplicateJSONFields struct { type DuplicateJSONFields struct {
JSON int `json:"a"` JSON int `json:"a"`
DuplicateJSON int `json:"a"` // ERROR "struct field DuplicateJSON repeats json tag .a. also at testdata/structtag.go:46" DuplicateJSON int `json:"a"` // ERROR "struct field DuplicateJSON repeats json tag .a. also at structtag.go:46"
IgnoredJSON int `json:"-"` IgnoredJSON int `json:"-"`
OtherIgnoredJSON int `json:"-"` OtherIgnoredJSON int `json:"-"`
OmitJSON int `json:",omitempty"` OmitJSON int `json:",omitempty"`
OtherOmitJSON int `json:",omitempty"` OtherOmitJSON int `json:",omitempty"`
DuplicateOmitJSON int `json:"a,omitempty"` // ERROR "struct field DuplicateOmitJSON repeats json tag .a. also at testdata/structtag.go:46" DuplicateOmitJSON int `json:"a,omitempty"` // ERROR "struct field DuplicateOmitJSON repeats json tag .a. also at structtag.go:46"
NonJSON int `foo:"a"` NonJSON int `foo:"a"`
DuplicateNonJSON int `foo:"a"` DuplicateNonJSON int `foo:"a"`
Embedded struct { Embedded struct {
DuplicateJSON int `json:"a"` // OK because its not in the same struct type DuplicateJSON int `json:"a"` // OK because its not in the same struct type
} }
AnonymousJSON `json:"a"` // ERROR "struct field AnonymousJSON repeats json tag .a. also at testdata/structtag.go:46" AnonymousJSON `json:"a"` // ERROR "struct field AnonymousJSON repeats json tag .a. also at structtag.go:46"
XML int `xml:"a"` XML int `xml:"a"`
DuplicateXML int `xml:"a"` // ERROR "struct field DuplicateXML repeats xml tag .a. also at testdata/structtag.go:60" DuplicateXML int `xml:"a"` // ERROR "struct field DuplicateXML repeats xml tag .a. also at structtag.go:60"
IgnoredXML int `xml:"-"` IgnoredXML int `xml:"-"`
OtherIgnoredXML int `xml:"-"` OtherIgnoredXML int `xml:"-"`
OmitXML int `xml:",omitempty"` OmitXML int `xml:",omitempty"`
OtherOmitXML int `xml:",omitempty"` OtherOmitXML int `xml:",omitempty"`
DuplicateOmitXML int `xml:"a,omitempty"` // ERROR "struct field DuplicateOmitXML repeats xml tag .a. also at testdata/structtag.go:60" DuplicateOmitXML int `xml:"a,omitempty"` // ERROR "struct field DuplicateOmitXML repeats xml tag .a. also at structtag.go:60"
NonXML int `foo:"a"` NonXML int `foo:"a"`
DuplicateNonXML int `foo:"a"` DuplicateNonXML int `foo:"a"`
Embedded struct { Embedded struct {
DuplicateXML int `xml:"a"` // OK because its not in the same struct type DuplicateXML int `xml:"a"` // OK because its not in the same struct type
} }
AnonymousXML `xml:"a"` // ERROR "struct field AnonymousXML repeats xml tag .a. also at testdata/structtag.go:60" AnonymousXML `xml:"a"` // ERROR "struct field AnonymousXML repeats xml tag .a. also at structtag.go:60"
Attribute struct { Attribute struct {
XMLName xml.Name `xml:"b"` XMLName xml.Name `xml:"b"`
NoDup int `xml:"b"` // OK because XMLName above affects enclosing struct. NoDup int `xml:"b"` // OK because XMLName above affects enclosing struct.
Attr int `xml:"b,attr"` // OK because <b b="0"><b>0</b></b> is valid. Attr int `xml:"b,attr"` // OK because <b b="0"><b>0</b></b> is valid.
DupAttr int `xml:"b,attr"` // ERROR "struct field DupAttr repeats xml attribute tag .b. also at testdata/structtag.go:76" DupAttr int `xml:"b,attr"` // ERROR "struct field DupAttr repeats xml attribute tag .b. also at structtag.go:76"
DupOmitAttr int `xml:"b,omitempty,attr"` // ERROR "struct field DupOmitAttr repeats xml attribute tag .b. also at testdata/structtag.go:76" DupOmitAttr int `xml:"b,omitempty,attr"` // ERROR "struct field DupOmitAttr repeats xml attribute tag .b. also at structtag.go:76"
AnonymousXML `xml:"b,attr"` // ERROR "struct field AnonymousXML repeats xml attribute tag .b. also at testdata/structtag.go:76" AnonymousXML `xml:"b,attr"` // ERROR "struct field AnonymousXML repeats xml attribute tag .b. also at structtag.go:76"
} }
} }
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment