Commit 709da955 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/go: run vet on packages with only cgo files

CgoFiles is not included in GoFiles, so we need to check both.

Fixes #24193

Change-Id: I6a67bd912e3d9a4be0eae8fa8db6fa8a07fb5df3
Reviewed-on: https://go-review.googlesource.com/99175
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
parent a3b3284d
...@@ -3233,6 +3233,16 @@ func TestGoVetWithOnlyTestFiles(t *testing.T) { ...@@ -3233,6 +3233,16 @@ func TestGoVetWithOnlyTestFiles(t *testing.T) {
tg.run("vet", "p") tg.run("vet", "p")
} }
// Issue 24193.
func TestVetWithOnlyCgoFiles(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
tg.tempFile("src/p/p.go", "package p; import \"C\"; func F() {}")
tg.setenv("GOPATH", tg.path("."))
tg.run("vet", "p")
}
// Issue 9767, 19769. // Issue 9767, 19769.
func TestGoGetDotSlashDownload(t *testing.T) { func TestGoGetDotSlashDownload(t *testing.T) {
testenv.MustHaveExternalNetwork(t) testenv.MustHaveExternalNetwork(t)
......
...@@ -62,11 +62,11 @@ func runVet(cmd *base.Command, args []string) { ...@@ -62,11 +62,11 @@ func runVet(cmd *base.Command, args []string) {
base.Errorf("%v", err) base.Errorf("%v", err)
continue continue
} }
if len(ptest.GoFiles) == 0 && pxtest == nil { if len(ptest.GoFiles) == 0 && len(ptest.CgoFiles) == 0 && pxtest == nil {
base.Errorf("go vet %s: no Go files in %s", p.ImportPath, p.Dir) base.Errorf("go vet %s: no Go files in %s", p.ImportPath, p.Dir)
continue continue
} }
if len(ptest.GoFiles) > 0 { if len(ptest.GoFiles) > 0 || len(ptest.CgoFiles) > 0 {
root.Deps = append(root.Deps, b.VetAction(work.ModeBuild, work.ModeBuild, ptest)) root.Deps = append(root.Deps, b.VetAction(work.ModeBuild, work.ModeBuild, ptest))
} }
if pxtest != nil { if pxtest != nil {
......
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