]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/vet: don't exit with failure on type checking error
authorIan Lance Taylor <iant@golang.org>
Wed, 2 Aug 2017 19:06:58 +0000 (12:06 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 3 Aug 2017 04:22:02 +0000 (04:22 +0000)
The vet tool only reports a type checking error when invoked with -v.
Don't let that by itself cause vet to exit with an error exit status.

Updates #21188

Change-Id: I172c13d46c35d49e229e96e833683d8c82a77de7
Reviewed-on: https://go-review.googlesource.com/52851
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
src/cmd/vet/main.go
src/cmd/vet/testdata/cgo/cgo3.go [new file with mode: 0644]
src/cmd/vet/vet_test.go

index 77376c90ed16bb0fbb7e4107c5cf07693a775536..34c5297b89f9e7faeef89a4291819b31d7c47fd5 100644 (file)
@@ -349,8 +349,9 @@ func doPackage(directory string, names []string, basePkg *Package) *Package {
        pkg.files = files
        // Type check the package.
        err := pkg.check(fs, astFiles)
-       if err != nil && *verbose {
-               warnf("%s", err)
+       if err != nil {
+               // Note that we only report this error when *verbose.
+               Println(err)
        }
 
        // Check.
diff --git a/src/cmd/vet/testdata/cgo/cgo3.go b/src/cmd/vet/testdata/cgo/cgo3.go
new file mode 100644 (file)
index 0000000..0b1518e
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Used by TestVetVerbose to test that vet -v doesn't fail because it
+// can't find "C".
+
+package testdata
+
+import "C"
+
+func F() {
+}
index b3d5c663a714c755503a254f74f41a2dc5aff312..8db8ff4d20266f2a325920551275d1aa09689c5c 100644 (file)
@@ -205,3 +205,15 @@ func TestTags(t *testing.T) {
                })
        }
 }
+
+// Issue #21188.
+func TestVetVerbose(t *testing.T) {
+       t.Parallel()
+       Build(t)
+       cmd := exec.Command("./"+binary, "-v", "-all", "testdata/cgo/cgo3.go")
+       out, err := cmd.CombinedOutput()
+       if err != nil {
+               t.Logf("%s", out)
+               t.Error(err)
+       }
+}